Skip to content

Instantly share code, notes, and snippets.

@derak-kilgo
Last active September 23, 2021 14:50
Show Gist options
  • Save derak-kilgo/b0c5a2f6834e64741d931f504fee28dc to your computer and use it in GitHub Desktop.
Save derak-kilgo/b0c5a2f6834e64741d931f504fee28dc to your computer and use it in GitHub Desktop.
MySQL Debug Cheatsheet
-- These are mostly MySQL Specific commands.
-- probe your query log settings. This will show you if its on or not and where its going (db or file)
SHOW VARIABLES LIKE 'general%'
;
-- saves the query log to a table in mysql. This is usually easier to get to.
SET GLOBAL log_output = 'table'
;
-- Disable the general query log. The log fills up fast. Turn it on, do your test and turn it off.
SET GLOBAL general_log = 0
;
-- turn on the general query log. Every statement executed will be saved.
SET GLOBAL general_log = 1
;
-- A way to view the query log. The convert() is required to get most sql editors (MySQL Workbench for example) to display the query in the grid view.
SELECT
mysql.general_log.*, convert(mysql.general_log.argument using utf8) as qy
FROM
mysql.general_log
-- you can filter more if needed. example:
-- where argument like 'student.*'
;
-- Empty the query log.
TRUNCATE mysql.general_log
;
@derak-kilgo
Copy link
Author

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