Last active
December 16, 2015 08:49
-
-
Save pjama/5408537 to your computer and use it in GitHub Desktop.
Script to load test database from dump file. Command line usage: `script.sh db_name`
This file contains hidden or 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 | |
DATABASE=$1 | |
TEST_DB_FILE="test_db.tar.gz" | |
mysql -uroot -e "drop database if exists $DATABASE;" | |
mysql -uroot -e "create database $DATABASE;" | |
mysql -uroot -e "show databases;" | |
if [ ! -f $TEST_DB_FILE ]; then | |
echo "Error: Missing test database." | |
exit -1 | |
fi | |
echo -e "\nLoading test database from dump..." | |
tar -xOzf $TEST_DB_FILE | mysql -uroot $DATABASE | |
mysql -uroot -e "show databases;" | |
echo "Complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment