通過mysqldumpslow來分析日誌
阿新 • • 發佈:2018-05-31
export avg utf8 log sch fse 信息 設置 mysql-
通過mysqldumpslow來分析日誌。
將mysql加入到全局變量中!!!
sudo vim /etc/profile
# 添加Mysql
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
前提是這個日誌文件需要設置可訪問權限。
最好還是弄一個軟連接到/usr/bin
下面。
sudo ln -s /usr/local/mysql/bin/mysqldumpslow /usr/bin/mysqldumpslow
列出了最慢的三條日誌信息。
sudo mysqldumpslow -t 3 /tmp/mysql-slow.log Reading mysql slow query log from /tmp/mysql-slow.log Count: 1 Time=0.33s (0s) Lock=0.00s (0s) Rows=23.0 (23), root[root]@localhost SELECT *, `TABLE_SCHEMA` AS `Db`, `TABLE_NAME` AS `Name`, `TABLE_TYPE` AS `TABLE_TYPE`, `ENGINE` AS `Engine`, `ENGINE` AS `Type`, `VERSION` AS `Version`, `ROW_FORMAT` AS `Row_format`, `TABLE_ROWS` AS `Rows`, `AVG_ROW_LENGTH` AS `Avg_row_length`, `DATA_LENGTH` AS `Data_length`, `MAX_DATA_LENGTH` AS `Max_data_length`, `INDEX_LENGTH` AS `Index_length`, `DATA_FREE` AS `Data_free`, `AUTO_INCREMENT` AS `Auto_increment`, `CREATE_TIME` AS `Create_time`, `UPDATE_TIME` AS `Update_time`, `CHECK_TIME` AS `Check_time`, `TABLE_COLLATION` AS `Collation`, `CHECKSUM` AS `Checksum`, `CREATE_OPTIONS` AS `Create_options`, `TABLE_COMMENT` AS `Comment` FROM `information_schema`.`TABLES` t WHERE `TABLE_SCHEMA` COLLATE utf8_bin IN ('S') ORDER BY Name ASC LIMIT N OFFSET N Count: 1 Time=0.05s (0s) Lock=0.00s (0s) Rows=1.0 (1), root[root]@localhost SELECT COUNT(*) FROM `sakila`.`film_actor` Count: 1 Time=0.04s (0s) Lock=0.00s (0s) Rows=1.0 (1), root[root]@localhost SELECT COUNT(*) FROM `sakila`.`rental`
通過mysqldumpslow來分析日誌