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!

Leave a Reply

Your email address will not be published. Required fields are marked *