Skip to content

Instantly share code, notes, and snippets.

@voor
Last active August 29, 2015 14:22
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 voor/c08864797a4337c10106 to your computer and use it in GitHub Desktop.
Save voor/c08864797a4337c10106 to your computer and use it in GitHub Desktop.
Create MySQL Database and User
# Adopted from http://jetpackweb.com/blog/2009/07/20/bash-script-to-create-mysql-database-and-user/
# Replace $mysqlroot with root password
# Replace $dbname with database name
# Replace $dbuser with database user
# Replace $dbpasswd with password
mysql -u root -p$mysqlroot <<-EOF
CREATE DATABASE $dbname;
GRANT ALL PRIVILEGES ON $database.* TO '$dbuser'@'localhost' \
IDENTIFIED BY '$dbpasswd';
FLUSH PRIVILEGES;
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment