6
mysql日志记录(1)慢查询
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.
mysql日志记录(1)慢查询
祈雨的博客
2017-11-05
1、默认值
MySQL默认关闭慢查询:
mysql> show variables like 'slow_query_log';
MySQL默认查询时间大于10秒的SQL语句为慢查询:
mysql> show variables like 'long_query_time';
2、打开慢查询
启动慢查询日志:
mysql> set global slow_query_log=on;
修改慢查询的时间阀值为3秒:
mysql> set global long_query_time=3;
注 long_query_time字段的值必须退出MySQL重新登录才会刷新数据。
mysql> select sleep(4);
慢查询日志默认为mysql/datadir/localhost-slow.log
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK