How to enable MySQL query logging

Posted . Visible to the public.

This will make MySQL log all received queries so you can see for yourself what happens on the database level.

Don't switch this on for production machines!

  1. Edit your my.cnf:
    sudo vim /etc/mysql/my.cnf
  2. In the [mysqld] section, add:
    log=/var/log/mysql.log
  3. Restart your MySQL daemon. On Ubuntu:
    sudo service mysql restart

Note that your MySQL performance will suffer. But when you need to enable query logging for a debug fest, you probably don't care about that.

Arne Hartherz
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2012-07-20 14:40)