This is the relevant section from /etc/my.cnf:

slow-query-log            = ON
long_query_time           = 2
log_slow_queries          = /var/log/mysql-slow.log

The problem is that file is missing and even if I touch it , nothing get written there. I've tried changing the log location to $datadir/mysql-slow.log and in the /etc/my.cnf file it looks like this:

log_slow_queries          = mysql-slow.log

I've forgot to mention that the user and owner of the mysql-slow.log file are mysql. But it doesn't work as well, any idea how to fix it?

[root@dbsrv ~]# grep slow /etc/my.cnf 
slow-query-log              = ON
log_slow_queries            = /var/log/mysql/mysql-slow.log 
slow-query-log              = ON
log_slow_queries            = /var/log/mysql/slow.log
[root@dbsrv ~]# ll /var/log/mysql/slow.log ; ll /var/log/mysql/mysql-slow.log
-rwxrwxrwx 1 mysql mysql 0 2014-02-04 18:23 /var/log/mysql/slow.log
-rwxrwxrwx 1 mysql mysql 0 2014-02-04 18:23 /var/log/mysql/mysql-slow.log
[root@dbsrv ~]# 

Thanks in advance

  • What version of MySQL are you using ??? – RolandoMySQLDBA Feb 4 '14 at 17:00
  • I use MYSQL version 5.5.33 . – Itai Ganot Feb 5 '14 at 9:40

It needs to be present and writeable by the mysqld uid when mysqld starts up, hence:

# touch /var/log/mysql-slow.log
# chown mysql /var/log/mysql-slow.log
# /etc/init.d/mysqld restart

(or, instead of restarting the server, you can do mysqladmin -u root flush-logs)

If it's still not writing to the file, check that you do actually have slow queries! And look at the MySQL error log for clues.

  • I cannot restart the mysqld service as I'm concerned it will drop replication but I tried mysqladmin -u root flush-logs and service mysqld reload but it still doesn't write to the log... – Itai Ganot Feb 6 '14 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.