Created
November 27, 2017 15:09
-
-
Save viklund/89269929d1fa7caa0ac7ba39f7b2e6eb to your computer and use it in GitHub Desktop.
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 | |
MYSQL_PORT=3366 | |
MYSQL_HOST=127.0.0.1 | |
MYSQL_PASS=rootpw | |
# Start a mysql instance with docker for example like this: | |
docker volume create swefreq-mysql-data | |
docker run -v swefreq-mysql-data:/var/lib/mysql --rm --name mysql -e MYSQL_ROOT_PASSWORD=$MYSQL_PASS -d -p $MYSQL_PORT:3306 mysql | |
# Wait for it to start | |
while ! mysql -uroot -p$MYSQL_PASS -h127.0.0.1 -P$MYSQL_PORT -e exit 2>/dev/null; do | |
echo -ne "\rWaiting for mysql to initialize..."; | |
sleep 1; | |
done | |
echo " DONE"; | |
# Create swefreq user and database | |
mysql -u root -P$MYSQL_PORT -h$MYSQL_HOST -p$MYSQL_PASS <<__END__ | |
CREATE USER IF NOT EXISTS 'swefreq'; | |
CREATE DATABASE IF NOT EXISTS swefreq_test; | |
GRANT ALL ON swefreq_test.* TO 'swefreq'@'%'; | |
__END__ | |
# Fill in with basic database structure | |
mysql -u swefreq -P$MYSQL_PORT -h$MYSQL_HOST swefreq_test < sql/swefreq.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment