mysql 查看slow query_MySQL慢查询日志(slow log)

1.基本知识:

mysql> show variables like '%slow%';

+---------------------+--------------------------------------------+

| Variable_name       | Value                                      |

+---------------------+--------------------------------------------+

| log_slow_queries    | ON                                         |

| slow_launch_time    | 2                                          |

| slow_query_log      | ON                                         |

| slow_query_log_file | /usr/local/mysql55/data/localhost-slow.log |

+---------------------+--------------------------------------------+

mysql> show variables like '%long%';

+---------------------------------------------------+----------+

| Variable_name                                     | Value    |

+---------------------------------------------------+----------+

| long_query_time                                   | 6.000000 |

The minimum and default values oflong_query_timeare 0 and 10, respectively. The value can be specified to a resolution of microseconds-long_query_time 的最小值是0-10,从 5.1版本开始可以以微秒记录SQL语句运行时间,之前仅用秒为单位记录。

To specify the initial slow query log state explicitly, use --slow_query_log[={0|1}].

为了显示的制定慢查询日志状态,使用slow_query_log=[0|1]

To specify a log file name, use --slow_query_log_file=file_name. To specify the log destination, use --log-output 【--log-output=[TABLE|FILE|NONE]:This option determines the destination for general query log and slow query log output】

为了指定logfile 文件名,使用--slow_query_log_file=file_name,为了指定慢日志的存放目的地(file or table or disableed ),使用参数--log-output  Before 5.1.6, the slow query log destination is always a file.

The older option to enable the slow query log file, --log-slow-queries, is deprecated.

5.1.29版本之前使用启动参数--log-slow-queries(参数 log_slow_queries)

总结:

1,设置 set  log-slow-queries=[TABLE|FILE|NONE] ;

2.设置 set  slow_query_log_file='/usr/local/mysql55/data/localhost-slow.log'

3.设置 setlog-slow-queries=on|1 【5.1.29之前的版本】    |  set slow_query_log=1  ;

4.设置 set long_query_time=XXX;

后续补充……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值