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.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

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
10 months 19 days ago

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!

10 months 11 days ago

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.