MySQL: How to Log General and Long Running Queries into Log Table

In this post, I provide different parameters to enable logging for General and Long running queries in MySQL.
Using this approach, you do not require to restart your MySQL Server. You can easily configure this log parameter and you can see the output in Log table.

As a Database Administrator, it is our responsibility to log all different kinds of queries because the log is our primary requirement for any kind of troubleshooting.

First check, current status of the different Log Parameters:

Using above statement, you can check the current value of log parameter.

Now enable logging for general query and save the output into “mysql.general_log” table:

Now enable logging for long running queries:

Sometimes, it is required to execute the FLUSH command of log to get immediate updates into the Log Table.

Anvesh Patel

Leave a Reply

2 Comments on "MySQL: How to Log General and Long Running Queries into Log Table"

Notify of
Sort by:   newest | oldest | most voted

I wwas suggested this website by my cousin. I’m not sure whether
this post is written by him as nobody else know sch
detailed about my trouble. You’re incredible! Thanks!


Heey There. I found your blog using msn. This is a very well written article.
I will be sure to bookmark iit and come back to
read more of your useful information. Thanks for the post.

I will certainly comeback.