MySQL Logging Notes

Enabling some extra logging options on MySQL is useful for temporary close analysis of what is actually going on with your server and applications.

Logging Slow Queries

To switch on the logging of queries which take a long time (default 10 seconds) enter the following line into my.cnf:

[mysqld]
log-slow-queries

This will give details on long queries typically in the following log file:

/path/to/mysql/data/hostname-slow.log

Or we can specify the log file location in my.cnf as follows:

log-slow-queries        = /var/log/mysql/mysql-slow.log

Logging All MySQL SQL Queries

If you want to check up on the actual SQL queries performed on MySQL logging can be switched on in your my.cnf file as follows:

log             = /var/log/mysql.log

Beware though that this is a big performance hit so should only be used when necessary.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>