Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created July 9, 2021 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/419303d6dc040941b97e7f82ca14ff05 to your computer and use it in GitHub Desktop.
Save ziadoz/419303d6dc040941b97e7f82ca14ff05 to your computer and use it in GitHub Desktop.
Wait for MySQL to Start
#!/usr/bin/env bash
# Load dot environment file:
export $(cat .env | xargs)
# Wait for MySQL service to start (this could be on the host or in a Docker container):
until mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e '\q'; do
>&2 echo "MySQL container is unavailable - sleeping"
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment