Skip to content

Instantly share code, notes, and snippets.

@christophlehmann
Created October 8, 2023 21:11
Show Gist options
  • Save christophlehmann/7be88a9bde74c9be47b4b1ccfe859556 to your computer and use it in GitHub Desktop.
Save christophlehmann/7be88a9bde74c9be47b4b1ccfe859556 to your computer and use it in GitHub Desktop.
Follow MySQLs general log
#!/bin/bash
trap 'mysql -e "SET GLOBAL general_log=0"; exit' SIGINT SIGQUIT
log_file="$(mysql -N -e 'SHOW VARIABLES WHERE variable_name="general_log_file"' | awk '{print $2}')"
test -f $log_file && rm $log_file
mysql -e "SET GLOBAL general_log=1"
tail -f $log_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment