MySQL queries snapshot

The gathering of the general logs would adversely affect the performance, it would take the significant space on your devices. The continuity of this log is neighter used. But sometimes it would be nice to see what is going on at runtime – I used to do the fallowing hack:

# MySQL configuration file my.cnf
general_log=1
general_log_file=/var/log/mysql/general.log

Bash:

root> /etc/init.d/mysql.server stop
root> rm -f /var/log/mysql/general.log
root> ln -s /dev/null /var/log/mysql/general.log
root> /etc/init.d/mysql.server start

In order to see content of logs you have to remove symbolic link and flush logs – in SQL mode:

root> rm -f /var/log/mysql/general.log

The wonder thing is that when I read carefuly the manual I would know that I can do it at runtime with pure SQL:

SET GLOBAL general_log = 'ON';
  1. No comments yet.

  1. No trackbacks yet.