It’s nice to see what the actual queries that run are on your site. Its pretty simple to set up! In your home folder, edit your .bashrc (or equivalent) and slap in the following:

alias tmysql='mysql -u root -e '\''SET GLOBAL general_log = "ON"'\'';sudo tail -f /var/log/mysql/general.log;mysql -u root -e '\''SET GLOBAL general_log = "OFF"'\''; sudo rm /var/log/mysql/general.log; echo '\''\nExiting Tail, Log Deleted.'\'';

Tweaking paths where required, obviously. Now close and open your terminal again, and when you type tmysql, you’ll start tailing MySQL! Sample output below!

          453 Query    SELECT `main_table`.* FROM `enterprise_customersegment_segment` AS `main_table`
          453 Query    SELECT `op_imagecdn_cache`.* FROM `op_imagecdn_cache` WHERE (`op_imagecdn_cache`.`url`='http:blah.com')
          453 Query    SELECT `main_table`.* FROM `madskull_autoblocks` AS `main_table` WHERE (identifier = 'trust-banners')
          453 Query    SELECT `madskull_autoblocks_definitions`.* FROM `madskull_autoblocks_definitions` WHERE (`madskull_autoblocks_definitions`.`id`='39')
Advertisements