Last active
September 23, 2021 14:50
-
-
Save derak-kilgo/b0c5a2f6834e64741d931f504fee28dc to your computer and use it in GitHub Desktop.
MySQL Debug Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dev.mysql.com/doc/refman/5.7/en/query-log.html