MySQL General query logs

MySQL prints each query in General query logs. This can be helpful in application profiling if you want to see how many and which queries are being run in a transaction and when commit/rollback is executed.

You can enable MySQL general query logs by running below sql command from root user:

SET GLOBAL general_log = 'ON';

By default, logs will be stored at /var/log/query.log ,  If you are getting the “permission error” after running above command.

Edit your mysqld.conf file which is located under /etc/mysql/mysql.conf.d ( This location may be different for your installation )

vi /etc/mysql/mysql.conf.d/mysqld.conf

and change the value of

general_log_file = /var/log/query.log

to

general_log_file = /var/lib/mysql/your_log_filename.log

In my case default general query log file location was /var/log/query.log & MySQL didn’t had permission to write at that location.

Credits : Chirag Jain

One thought on “MySQL General query logs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s