Skip to content

Instantly share code, notes, and snippets.

@craigvantonder
Last active December 1, 2024 10:27
Show Gist options
  • Save craigvantonder/eb229e5143189b678701557c7dd00928 to your computer and use it in GitHub Desktop.
Save craigvantonder/eb229e5143189b678701557c7dd00928 to your computer and use it in GitHub Desktop.
Enable, view and disable the general logging in MySQL.

Sometimes it is useful to enable query logging for debugging purposes, this will log all queries so that you can see which users are doing what.

Turn it on (https://stackoverflow.com/a/14404000/2110294)

SET global general_log = on;
SET global log_output = 'table';

List logs

SELECT * FROM mysql.general_log; 

List queries (https://dba.stackexchange.com/a/192861)

SELECT a.*, convert(a.argument USING utf8) FROM mysql.general_log a;

Turn it off

SET global general_log = off;

Remove log data

TRUNCATE mysql.general_log;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment