Saturday 7 September 2013

Enable MySQL slow query log

Posted by Sarath On Saturday, September 07, 2013 No comments
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 too easy..  ;)

0 comments: