Last active
August 29, 2015 14:13
-
-
Save gorbiz/c897800a27fa4f03578c to your computer and use it in GitHub Desktop.
Turn MySQL logging on & off
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 | |
if [ "$1" = "on" ]; then | |
mysql -e 'SET GLOBAL log_output = "FILE"; SET GLOBAL general_log_file = "/tmp/mysql.log"; SET GLOBAL general_log = "ON";' | |
echo "mysql log ON: /tmp/mysql.log" | |
elif [ "$1" = "off" ]; then | |
mysql -e 'SET GLOBAL general_log = "OFF";' | |
echo "mysql log OFF" | |
elif [ "$1" = "tail" ]; then | |
mysql -e 'SET GLOBAL log_output = "FILE"; SET GLOBAL general_log_file = "/tmp/mysql.log"; SET GLOBAL general_log = "ON";' | |
echo "tailing mysql log /tmp/mysql.log..." | |
tail -f /tmp/mysql.log | |
else | |
echo "Usage: sqlog on|off|tail" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment