Steps to enable mysql query log on mysql server without restarting mysql process on Ubuntu and other Linux flavours.
- Set general_log_file on SQL prompt:
SET GLOBAL general_log_file = '/var/log/mysql/query.log';
- set general_log to value ‘ON’
SET GLOBAL general_log = 'ON';
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
- 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.