Mysql query logging

You can log every mysql-query to a log file easily:


mysql> SHOW VARIABLES LIKE "general_log%";


+------------------+----------------------------+
| Variable_name | Value |
+------------------+----------------------------+
| general_log | OFF |
| general_log_file | /var/run/mysqld/mysqld.log |
+------------------+----------------------------+


mysql> SET GLOBAL general_log = 'ON';

Do your queries (on any db). Grep or otherwise examine /var/run/mysqld/mysqld.log
Then don’t forget to


mysql> SET GLOBAL general_log = 'OFF';

or the performance will plummet and your disk will fill!

No Comments »

Ray on July 1st 2012 in Miscellaneous

Trackback URI | Comments RSS

Leave a Reply