Created
March 22, 2017 18:04
-
-
Save kokoye2007/2c92324dd1652c3e5e8fa546020090c0 to your computer and use it in GitHub Desktop.
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 | |
source ~/.digitalocean_password | |
MAX_ARGS=3 | |
BAD_ARG=65 | |
SQL=`which mysql` | |
CMD1="CREATE DATABASE IF NOT EXISTS $1;" | |
CMD2="GRANT USAGE ON *.* TO $2@localhost IDENTIFIED BY '$3';" | |
CMD3="GRANT ALL PRIVILEGES ON $1.* TO $2@localhost;" | |
CMD4="FLUSH PRIVILEGES;" | |
SQLCMD="${CMD1}${CMD2}${CMD3}${CMD4}" | |
if [ $# -ne $MAX_ARGS ] | |
then | |
echo "Usage: $0 dbname dbuser dbpass" | |
exit $BAD_ARG | |
fi | |
$SQL -uroot -p$root_mysql_pass -e "$SQLCMD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment