Last active
August 29, 2015 14:05
-
-
Save yevrah/d6e93623008b324f9f01 to your computer and use it in GitHub Desktop.
Remote Tail MySQL General Log
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
#!/bin/sh | |
# Usage | |
# tail_mysql.sh user@host | |
# | |
# Notes | |
# If you want to trace sql queries as they are run, be sure to enable | |
# the general log, use the following comman | |
# mysql -u user -p --execute "SET GLOBAL general_log = 'ON';" | |
ssh -t $1 "sudo tail -f \`set global general_log = on; mysql -B -N -e \"SELECT VARIABLE_VALUE FROM information_schema.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'general_log_file';\"\`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment