Created
June 3, 2022 20:41
-
-
Save stnguyen90/afbeb9586a638cd3ae2f561c7bf250d7 to your computer and use it in GitHub Desktop.
Enable the general query log for a MySQL/MariaDB docker container and tail it. Disable the general query log on exit.
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 | |
CONTAINER=appwrite-mariadb | |
if [ ! -z "$1" ]; then | |
CONTAINER=$1 | |
fi | |
docker exec -it $CONTAINER sh -c 'mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE -e "SET GLOBAL general_log=1"' | |
docker exec -it $CONTAINER sh -c 'tail -f /var/lib/mysql/$HOSTNAME.log' | |
docker exec -it $CONTAINER sh -c 'mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE -e "SET GLOBAL general_log=0"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment