This was first published here.
MySQL can log every activity in General query logs. This can be helpful in application profiling when you want to see which queries are being executed or when a commit or rollback is executed. It can also be helpful in applications which use ORM as logs shows raw SQL.
You can enable MySQL general query logs by running below query in MySQL console :
SET GLOBAL general_log = 'ON';
Note : You don't need to restart MySQL server.
you can check log file location using below command.
show variables like 'general_log_file';
It will show you a location like :- /var/lib/mysql/filename.log
Now you can analyse your logs to find some useful information. If size of logs generated is heavy you can consider analysing it using a tool like pt-query-digest (https://www.percona.com/doc/percona-toolkit/LATEST/pt-query-digest.html) which is provided by Percona.
You can disable it using,
SET GLOBAL general_log = 'OFF';
For more information & options you can read the official documentation here.
https://dev.mysql.com/doc/refman/5.6/en/query-log.html
Top comments (0)