mysql 5.7 log-slow-queries error
Asked Answered
M

2

14

I'm trying to enable Slow Query Logging on mysql 5.7 and getting this error:

2016-04-27T14:55:51.934612Z 0 [ERROR] unknown variable 'log-slow-queries=/var/log/mysql-query.log'

2016-04-27T14:55:51.934639Z 0 [ERROR] Aborting

In my /etc/my.cnf file I have "log-slow-queries=/var/log/mysql-query.log" defined, but I'm going to assume that in 5.7 that is invalid. What is the correct my.cnf settings to enable query logging? Thanks,

Myelencephalon answered 27/4, 2016 at 15:8 Comment(1)
Version 5.1.29 deprecated that syntax (and some other log syntax); 5.6.1 removed it. What was generating it?Bister
W
19

Name of the MySQL system variable is slow_query_log_file

And to enable it, you need to set slow_query_log to ON or 1

MySQL Reference Manual: sysvar_slow_query_log_file

MySQL Reference Manual: sysvar_slow_query_log

Wandie answered 27/4, 2016 at 15:13 Comment(3)
Does slow query also mean "All queries"? My overall goal is to enable logging of all queries, yet all I see are comments about slow queries. There isn't some other flag for enabling all queries, is there?Myelencephalon
The general_log can log everything. And it can grow really fast. We only enable it temporarily for debugging. Reference: http://dev.mysql.com/doc/refman/5.7/en/query-log.htmlWandie
Have many awnsers in Stackoverflow using log-slow-queries to set the path... Thank you for the anwser.Mastitis
L
29

log-slow-queries is deprecated

See 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
Lauro answered 2/9, 2016 at 6:59 Comment(2)
The defaults in 5.7.20 as of this comment are incorrect. You'll have to update it manually as stated above.Pending
Also on mysqld command, it's now --slow-query-log, and NOT --log-slow-timeBurbank
W
19

Name of the MySQL system variable is slow_query_log_file

And to enable it, you need to set slow_query_log to ON or 1

MySQL Reference Manual: sysvar_slow_query_log_file

MySQL Reference Manual: sysvar_slow_query_log

Wandie answered 27/4, 2016 at 15:13 Comment(3)
Does slow query also mean "All queries"? My overall goal is to enable logging of all queries, yet all I see are comments about slow queries. There isn't some other flag for enabling all queries, is there?Myelencephalon
The general_log can log everything. And it can grow really fast. We only enable it temporarily for debugging. Reference: http://dev.mysql.com/doc/refman/5.7/en/query-log.htmlWandie
Have many awnsers in Stackoverflow using log-slow-queries to set the path... Thank you for the anwser.Mastitis

© 2022 - 2024 — McMap. All rights reserved.