To debug applications which use a mysql database, it comes in handy to enable the query log to get all SQL queries that were sent to the database.  Open the MySQL configuration file (my.cnf)

vi /etc/mysql/my.cnf

and add the line:


in the [mysql] section of the file. Depending on the Linux distribution that you use, the my.cnf file can be /etc/my.cnf or /etc/mysql/my.cnf.

Afterwards restart mysql to apply the new the configuration:

/etc/init.d/mysql restart


2 thoughts on “How to enable the query log in MySQL

  • September 7, 2011 at 8:47 pm

    I had a problem with the query.log file, its increasing its size but in my.cnf cant find a line with this file to log the querys. Is some other place where i can find mysql configuration? thanks

    • September 13, 2011 at 10:27 am

      Please check the files in the directory /etc/mysql/conf.d/


Leave a Reply

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