6

mysql日志记录(1)慢查询

 2 years ago
source link: https://wakzz.cn/2017/11/05/mysql/%E6%97%A5%E5%BF%97%E8%AE%B0%E5%BD%95(1)%E6%85%A2%E6%9F%A5%E8%AF%A2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

mysql日志记录(1)慢查询

祈雨的博客
2017-11-05

1、默认值

MySQL默认关闭慢查询:

mysql> show variables like 'slow_query_log';

12267808.jpg

MySQL默认查询时间大于10秒的SQL语句为慢查询:

mysql> show variables like 'long_query_time';

88729274.jpg

2、打开慢查询

启动慢查询日志:

mysql> set global slow_query_log=on;

修改慢查询的时间阀值为3秒:

mysql> set global long_query_time=3;

49367298.jpg

注 long_query_time字段的值必须退出MySQL重新登录才会刷新数据。

mysql> select sleep(4);

慢查询日志默认为mysql/datadir/localhost-slow.log

38432438.jpg


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK