Created
June 26, 2017 23:06
-
-
Save enzinier/f11b924cb57316aa7900c5a986a6e69c to your computer and use it in GitHub Desktop.
Job for initializing database when database is connected.
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/bash | |
OUTPUT="" | |
until [[ ! "$OUTPUT" == "" ]]; do | |
echo "Not Connect!" | |
OUTPUT=$(mysql -h127.0.0.1 -uroot -p$MYSQL_ROOT_PASSWORD -e "SHOW DATABASES;" 2>/dev/null) | |
sleep 1 | |
done | |
echo "Connect!" | |
FILES="/tmp/initialize_sql/*.sql" | |
for file in $FILES; | |
do | |
mysql -h127.0.0.1 -uroot -p$MYSQL_ROOT_PASSWORD < $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment