Last active
January 7, 2022 14:50
-
-
Save mmmunk/e46942f87985aba1a306dfeb9d57b0e4 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -e | |
DOCKER_LOG_FILE=/tmp/mysql-dev.log | |
OUTPUT_LOG_FILE=/tmp/mysql-dev-$(date +%s).log | |
function StopLog { | |
echo "Stopping MySQL log" | |
docker exec dev-db mysql --user=root --execute="set global general_log=0;" | |
docker exec dev-db rm -f $DOCKER_LOG_FILE | |
} | |
echo "Starting MySQL log" | |
docker exec dev-db rm -f $DOCKER_LOG_FILE | |
docker exec dev-db mysql --user=root --execute="set global log_output=FILE; set global general_log_file=\"$DOCKER_LOG_FILE\"; set global general_log=1;" | |
trap StopLog EXIT | |
echo -n "Run your SQL thing on DEV-DB and press [Enter] when done... "; read -r | |
docker cp dev-db:$DOCKER_LOG_FILE $OUTPUT_LOG_FILE | |
echo "Your log file is here:" $OUTPUT_LOG_FILE |
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
-- Log incoming SQL on MySQL server: | |
set global log_output=FILE; | |
set global general_log_file="C:/Test/MySQL.log"; | |
set global general_log=1; | |
-- Turn off: | |
set global general_log=0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment