Skip to content

Instantly share code, notes, and snippets.

@chrisjlee
Created March 23, 2013 06:28
Show Gist options
  • Save chrisjlee/5226686 to your computer and use it in GitHub Desktop.
Save chrisjlee/5226686 to your computer and use it in GitHub Desktop.
Create mysql database script
#!/bin/bash
# Help from http://drupal.org/documentation/install/create-database
echo '--------------------------------------------'
echo ' Create a database'
echo '--------------------------------------------'
echo '
'
echo 'Please enter a username to create for this new database:'
read UN
echo "Please provide a password for $UN"
read NUPW
echo 'Provide a database name'
read DB
echo '... You'll be prompted for root password'
mysql -uroot -p -e "create database $DB; create user '$UN'@'localhost' identified by '$NUPW'; grant all on $DB.* to '$UN'@'localhost' identified by $NUPW; flush privileges;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment