Skip to content

Instantly share code, notes, and snippets.

@ambakshi
Created June 6, 2013 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambakshi/5720026 to your computer and use it in GitHub Desktop.
Save ambakshi/5720026 to your computer and use it in GitHub Desktop.
Create a new mysql db for the given user/password
#!/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