Last active
December 19, 2016 12:12
-
-
Save dgoguerra/2a335b8c70cc692dab35d19928455a3b to your computer and use it in GitHub Desktop.
Create database and setup credentials
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
#!/usr/bin/env bash | |
bin="mysql" | |
#bin="/Applications/MySQLWorkbench.app/Contents/MacOS/mysql" | |
database=$1 | |
username=$2 | |
password=$3 | |
if [ ! "$password" ]; then | |
echo "usage: DB_HOST= DB_USER= DB_PASSWORD= command <database> <username> <password>" | |
exit 1 | |
fi | |
"$bin" -h"$DB_HOST" -u"$DB_USER" -p"$DB_PASSWORD" <<EOF | |
create database if not exists $database; | |
grant all on $database.* TO '$username'@'%' identified by '$password'; | |
flush privileges; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See created user accounts: