Skip to content

Instantly share code, notes, and snippets.

@yevrah
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yevrah/d6e93623008b324f9f01 to your computer and use it in GitHub Desktop.
Save yevrah/d6e93623008b324f9f01 to your computer and use it in GitHub Desktop.
Remote Tail MySQL General Log
#!/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