Enable MySQL slow query log

The slow query log consists of SQL statements that took more than long_query_time seconds to execute and required at least min_examined_row_limit rows to be examined. It is very helpful in troubleshooting bad queries.

Add the following to /etc/my.cnf file to enable the slow query log:
Code: 

log-slow-queries=/var/lib/mysql/slow.log

After that, then do the following commands to create the file with the right ownership and file permissions:

Code: 

touch /var/lib/mysql/slow.log

Code: 

chmod 660 /var/lib/mysql/slow.log

Code: 

chown mysql:mysql /var/lib/mysql/slow.log

Done..!! I hope that was easy..  🙂

About Sarath

A Techie from Kochi, India with 8+ years of experience in Linux and Windows server administration. I learn new things almost everyday and I enjoy the fun of learning and sharing my knowledge.

COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *