Skip to content

Instantly share code, notes, and snippets.

@jeandat
Last active October 16, 2015 12:24
Show Gist options
  • Save jeandat/031d58a62a6d38e5a082 to your computer and use it in GitHub Desktop.
Save jeandat/031d58a62a6d38e5a082 to your computer and use it in GitHub Desktop.
It is possible to activate mysql log in order to see all executed queries. Several options : table or file.
-- For those blessed with MySQL >= 5.1.12:
-- If you prefer to output to a table:
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
-- Take a look at the table mysql.general_log
-- If you prefer to output to a file:
SET GLOBAL log_output = "FILE"; which is set by default.
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
-- I prefer this method because:
-- * you're not editing the my.cnf file and potentially permanently turning on logging
-- * you're not fishing around the filesystem looking for the query log - or even worse, distracted by the need for the perfect destination. /var/log /var/data/log /opt /home/mysql_savior/var
-- * restarting the server leaves you where you started (log is off)
-- For more information, see MySQL 5.1 Reference Manual - Server System Variables - general_log
-- Solution found here : http://stackoverflow.com/questions/650238/how-to-show-the-last-queries-executed-on-mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment