1. 首先登录数据库查看是否开启了
show variables like '%slow%';
查看下slow_query_log
是on
还是off
2. 修改配置文件
vi /etc/my.cnf
slow_query_log=1 //开启
long_query_time=1 //超过1s算慢查询
log_queries_not_using_indexes=1 //记录没有索引的查询
show variables like '%slow%';
查看下slow_query_log
是on
还是off
vi /etc/my.cnf
slow_query_log=1 //开启
long_query_time=1 //超过1s算慢查询
log_queries_not_using_indexes=1 //记录没有索引的查询