Enable query log without restarting mysql on Linux

Steps to enable mysql query log on mysql server without restarting mysql process on Ubuntu and other Linux flavours.

  1. Set general_log_file on SQL prompt:
    SET GLOBAL general_log_file = '/var/log/mysql/query.log';
  2. set general_log to value ‘ON’
    SET GLOBAL general_log = 'ON';
  3. Check query log. You may have to use sudo in case you dont have read access to log file.

    $ tail -f /var/log/mysql/query.log
  4. In case you want to disable query log
    SET GLOBAL general_log = 'OFF';

Note that this approach is not mysql restart safe. To permanently enable query log, please visit Mysql – how to enable query log.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments