How to monitor mysql queries

Andy Wits Blog

Sometimes, you need to figure out which request comes from cms / cmf or another script to the Mysql server. For example, I had to deal with the jqgrid-php library. It was unclear which query comes to the mysql server from the script.

You can, of course, install and configure mysql-proxy, but there is a simpler solution:

  1. Login to Mysql-server as mysql admin (root) user.

  2. Set where to write the log:

set global general_log_file='/tmp/mysql_query.log';
  1. Enable log:
set global general_log = 1;
  1. Run your scripts

  2. Turn it off so it does not clog the server

set global general_log = 0;
  1. Analyze the log:
less /tmp/mysql_query.log
  1. it's all!
Published on Apr 14 2016 at 12:00 am
Time to read 1 minute(s)
Categories
  • System Administration

Contact me on