Skip to content

Instantly share code, notes, and snippets.

@stnguyen90
Created June 3, 2022 20:41
Show Gist options
  • Save stnguyen90/afbeb9586a638cd3ae2f561c7bf250d7 to your computer and use it in GitHub Desktop.
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.
#!/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