How to enable Slow Query Log

Append into /etc/my.cnf the following:

slow_query_log = 1
slow-query_log_file = /var/log/mysql-slow.log
long_query_time = 2

Create /var/log/mysql-slow.log log file and set it as mysql user:

touch /var/log/mysql-slow.log
chown mysql:mysql /var/log/mysql-slow.log

Restart MySQL server:


Monitor the logs using mysqldumpslow command:

mysqldumpslow -a /var/log/mysql-slow.log


Similar Posts:

Leave a Reply

Your email address will not be published.