mysql 5.7 log-slow-queries错误

Alb*_*lby 11 mysql my.cnf mysql-slow-query-log

我正在尝试在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设置是什么?谢谢,

Evg*_*nko 24

不推荐使用log-slow-queries

请参阅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
Run Code Online (Sandbox Code Playgroud)

  • 截至本评论的 5.7.20 中的默认值不正确。您必须如上所述手动更新它。 (2认同)

spe*_*593 13

MySQL系统变量的名称是 slow_query_log_file

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

MySQL参考手册:sysvar_slow_query_log_file

MySQL参考手册:sysvar_slow_query_log