Created
June 6, 2013 08:06
-
-
Save ambakshi/5720026 to your computer and use it in GitHub Desktop.
Create a new mysql db for the given user/password
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 | |
if [ $# -lt 3 ]; then | |
echo >&2 "$0 <db> <user> <pass>" | |
exit 2 | |
fi | |
db="$1" | |
db_user="$2" | |
db_pass="$3" | |
mysql <<EOF | |
CREATE DATABASE \`$db\`; | |
GRANT ALL PRIVILEGES ON \`$db\`.* TO "$db_user"@"localhost" IDENTIFIED BY "$db_pass"; | |
FLUSH PRIVILEGES; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment