14

我正在尝试在 mysql 5.7 上启用慢速查询日志记录并收到此错误:

2016-04-27T14:55:51.934612Z 0 [错误] 未知变量 'log-slow-queries=/var/log/mysql-query.log'

2016-04-27T14:55:51.934639Z 0 [错误] 中止

在我的 /etc/my.cnf 文件中,我定义了“log-slow-queries=/var/log/mysql-query.log”,但我假设在 5.7 中这是无效的。启用查询日志记录的正确 my.cnf 设置是什么?谢谢,

4

2 回答 2

29

不推荐使用日志慢查询

http://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html

# Here you can see queries with especially long duration
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow-queries.log
long_query_time = 1
于 2016-09-02T06:59:03.307 回答
18

MySQL系统变量的名称是slow_query_log_file

要启用它,您需要设置slow_query_log为 ON 或 1

MySQL 参考手册:sysvar_slow_query_log_file

MySQL 参考手册:sysvar_slow_query_log

于 2016-04-27T15:13:05.353 回答