Created
May 24, 2014 14:32
-
-
Save innesm4/80e97d5e842e131ee38d 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 | |
| echo -n "Enter the MySQL root password: " | |
| read -s rootpw | |
| echo -n "Enter database name: " | |
| read dbname | |
| echo -n "Enter database username: " | |
| read dbuser | |
| echo -n "Enter database user password: " | |
| read dbpw | |
| db="create database $dbname;GRANT ALL PRIVILEGES ON $dbname.* TO $dbuser@localhost IDENTIFIED BY '$dbpw';FLUSH PRIVILEGES;" | |
| mysql -u root -p$rootpw -e "$db" | |
| if [ $? != "0" ]; then | |
| echo "[Error]: Database creation failed" | |
| exit 1 | |
| else | |
| echo "------------------------------------------" | |
| echo " Database has been created successfully " | |
| echo "------------------------------------------" | |
| echo " DB Info: " | |
| echo "" | |
| echo " DB Name: $dbname" | |
| echo " DB User: $dbuser" | |
| echo " DB Pass: $dbpw" | |
| echo "" | |
| echo "------------------------------------------" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment