The code below is to enable MySQL General Logging without using the my.cnf file. I know you can just set a quick parameter in the my.cnf file to enable logging and set where I want it to go. But putting it in my.cnf is rather permanent as I’m likely to forget to remove it :) By running the following SQL commands, you can turn on logging and quickly turn it back off again. Or just leave it, and it will turn off the next time you restart MySQL or the server.
SET GLOBAL general_log='ON' SET GLOBAL log_output="TABLE"
I like to output to table so I can view the queries without having to keep downloading a file or “watching” the log file. If you would rather deal with a file, set the appropriate options just like you would in my.cnf but using SET GLOBAL instead.
This info is listed all over if you google for just a minute with the right terms (my.cnf method seems to be more popular than this way). Here’s just one place where I found it on StackOverflow.
I’m putting this here mainly for myself because I always find myself wasting about 5 minutes searching for it every time I need it.