Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "Please enter the name of the new DB to create:"
- read NEW_DB
- echo "Please enter the name of the new DB username:"
- read NEW_USER
- echo "Please enter the name of the new DB password:"
- read -s NEW_PASS
- echo "Please re-enter the name of the new DB password:"
- read -s NEW_PASS_CONFIRM
- if [ "$NEW_PASS" == "$NEW_PASS_CONFIRM" ]
- then
- echo "Creting new DB named $NEW_DB owned by $NEW_USER"
- echo "You will need the MySQL root password for this:"
- mysql -u root -p -e "CREATE USER '$NEW_USER'@'localhost' IDENTIFIED BY '$NEW_PASS';CREATE DATABASE $NEW_DB;GRANT ALL PRIVILEGES ON $NEW_DB . * TO '$NEW_USER'@'localhost';FLUSH PRIVILEGES;"
- if [ $? -eq 0 ]
- then
- echo "Database sucessfully created!"
- fi
- else
- echo "Passwords do not match please try again"
- fi
Add Comment
Please, Sign In to add comment