mysql 开启慢查询日志

时间:2021-11-23 06:06:01

 

 

查询设置:

show VARIABLES like '%slow_query_log%' ;
set GLOBAL slow_query_log =1;
show VARIABLES like 'long_query_time%';
set GLOBAL long_query_time =5;

 

设置配置文件参数[mysqld](需重启mysql服务):

slow_query_log =1
slow_query_log_file = /var/lib/mysql/slowquery.log
long_query_time = 10

 验证:

SELECT SLEEP(11)

 

参考文章:

http://www.cnblogs.com/luyucheng/p/6265594.html