开启MySQL慢查询日志

1. 修改 mysql 的配置文件 my.cnf

vi /etc/mysql/my.cnf

2. 在 [mysqld] 节点中添加内容

slow_query_log=TRUE                                # 开启慢日志 
slow_query_log_file=/var/log/mysql/mysql-slow.log  # 日志存放位置
long_query_time=5                             # 超时时间5秒(超过5秒就会被记录下来)

3. 登录 mysql 客户端,查看 slow_query_log 变量

show variables like '%quer%';
原文地址:https://www.cnblogs.com/tangxuliang/p/9078957.html