Published under MySQL.
The general log records every query that the MySQL database processes, with the parameters visible. This means you are able to see the values used in a bound query.
There are two ways to enable the MySQL general log:
Enable it in the configuration file. This will enable the general log when MySQL starts.
You can run a global query to enable the general log while the MySQL server is running.
To enable the general log via the configuration file, add the following to your configuration file (example path is
You must restart the MySQL server after editing the configuration file.
To enable the general log via a global query, you can run this query:
Now that the general log is enabled, you have a couple options on where the log is written to. By default, it’s written to a log file located at:
However, when I enable the general log for debugging, I often have the output written to a table, so I can query it easily. To write the output to a table, you can run this global query:
You can query the general log table via:
The results returned can be filtered, sorted, etc:
Subscribe to my newsletter to know when I publish more content in the future.