Slow Query Log Not Logging

Good afternoon,

we are trying to have access to our slow query log file at “/var/log/mysql/localhost-slow.log” but it looks like the file is empty. The “my.cnf” file says “!includedir /etc/my.cnf.d”, and inside that directory we have the following files:


Looking at the “server.cnf” file it looks like it’s set properly to write slow queries logs:

# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
# See the examples of server my.cnf files in /usr/share/mysql/

# this is read by the standalone daemon and embedded servers

# this is only for the mysqld standalone daemon
slow-query-log = 1
slow-query-log-file = /var/log/mysql/localhost-slow.log
long_query_time = 1
# this is only for embedded server

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here


Any idea on what could be the issue? We’ve tried to add the following:

slow-query-log = 1
slow-query-log-file = /var/log/mysql/localhost-slow.log
long_query_time = 1

directly into my.cnf and then restarting through service mysql restart but it didn’t work?

Thanks in advance for any help.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Have you login to your server via ssh and type those commands?

1.make dir mkdir /var/log/mysql

2.create empty file touch /var/log/mysql/localhost-slow.log

3.set permission for user mysql chown mysql:mysql -R /var/log/mysql

4.then restart mysql service mysql restart

mkdir /var/log/mysql
touch /var/log/mysql/log-slow-queries.log
chown mysql:mysql -R /var/log/mysql

I had the same problem but after google I got the code from It is working.