Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #echo -n "Enter the MySQL root password: "
- #read -s rootpw
- #echo -n "Enter database name: "
- #read dbname
- rootpw="rootmysqlpass"
- dbname="$1"
- ## REplace dashes with underscore
- database="${dbname/\-/_}"
- db="create database $database;GRANT ALL PRIVILEGES ON $database.* TO $database@localhost IDENTIFIED BY '$database';FLUSH PRIVILEGES;"
- mysql -u root -p$rootpw -e "$db"
- #mysql -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: $database"
- echo " DB User: $database"
- echo " DB Pass: $database"
- echo ""
- echo "------------------------------------------"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement