Recently while writing code against a development MySQL Database, I encountered the need to temporarily enable logging in MySQL to show me the last queries made by my application. I only needed to do this temporarily and did not want to mess with my my.cnf file, so the following steps came in handy.
While in MySQL with a privileged user do the following:
use mysql; SET GLOBAL log_output = 'TABLE'; SET GLOBAL general_log = 'ON'; |
Then run this query in MySQL:
select * from general_log; |
Alternatively you can do a running tail on the general_log.CSV outside of MySQL
tail -f /var/lib/mysql/mysql/general_log.CSV |
To reset things back to normal you can just restart mysql. Hope this helps in your troubleshooting or application to database sleuthing.