How to see what’s going on in your mysql database (linux)

You can see every SQL command which your mysql database receives.

In your mysql interface you can set where the log file will be written to and then turn on the logging option (change log filename as applicable):
set global general_log_file = ‘/var/log/mysql.log’;
set global general_log = ‘ON’;

(to see the value of these variables type:
show global variables where variable_name like ‘general_log%’;
in your mysql interface)

Now use:
tail -f /var/log/mysql.log

and you’ll see every new SQL statement which the database receives.

And of course to turn it all off again type this in the :
set global general_log = ‘OFF’;

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

Leave a Comment