Enable Logging of Slow MySQL Queries

October 10th, 2009 by tech Leave a reply »

MySQL has a feature that allows you to log slow running queries to a file. To enable you just need to add some lines to your my.cnf file, and restart.

Insert the following into /etc/my.cnf:

log-slow-queries = /var/log/mysql/mysql-slow.log
long_query_time = 5

Save my.cnf and do the following when you return to a shell:

#touch /var/log/mysql/mysql-slow.log
#chown mysql:mysql /var/log/mysql/mysql-slow.log
#service mysql restart

  • Share/Bookmark
Post Sponsored by

2 comments

  1. Polprav says:

    Hello from Russia!
    Can I quote a post in your blog with the link to you?

  2. tech says:

    Yes, certainly :)

Leave a Reply


cPanel Web Site Hosting by IntraHost