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
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: