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 )
and change the value of
general_log_file = /var/log/query.log
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