Ubuntu: enable MySQL logging

In /etc/mysql/my.cnf, under Logging and Replication, uncomment log

# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
log             = /var/log/mysql/mysql.log

Restart MySQL

sudo /etc/init.d/mysql restart

View queries

tail -f /var/log/mysql/mysql.log

Turn it off when you're done because:

  • impact on performance
  • file size can grow quickly

Reference

Feedback

In /etc/mysql/my.cnf:

log = /var/log/mysql/mysql.log
general_log = 1

Restart MySQL:

service mysql restart
Karel Picman
Sep 5, 2012
#1
As of v5.1 it is:

general_log_file = /var/log/mysql/mysql.log
general_log = 1

May 29, 2013
#2
How to setup binary logging?
Ankit
Aug 15, 2013
#3