mysql query logging

Locate my.cnf on your machine

sudo find / -name my.cnf -print

For me (on Ubuntu) my.cnf is located here:


… and also here, for local settings:


Uncomment the general log file lines:

 # * Logging and Replication
 # Both location gets rotated by the cronjob.
 # Be aware that this log type is a performance killer.
 # As of 5.1 you can enable the log at runtime!
 general_log_file        = /var/log/mysql/mysql.log
 general_log             = 1

Restart mysql:

sudo /etc/init.d/mysql restart

Be warned, the file created is *huge*, so you’ll want to switch off logging once you have debugged whatever is happening with your query.

As it happens, I was doing this while debugging something on a CiviCRM installation.

In the end, I used the second method (add debug code to CiviCRM) described here:

Posted in CiviCRM, drupal

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: