码迷,mamicode.com
首页 > 数据库 > 详细

通过mysqldumpslow来分析日志

时间:2018-05-31 02:33:43      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:upd   check   reading   source   update   auto   /tmp   pre   col   

通过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来分析日志

标签:upd   check   reading   source   update   auto   /tmp   pre   col   

原文地址:https://www.cnblogs.com/jiqing9006/p/9114551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!