Guest User

Untitled

a guest
Mar 1st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/bin/bash
  2. echo "Please enter the name of the new DB to create:"
  3. read NEW_DB
  4. echo "Please enter the name of the new DB username:"
  5. read NEW_USER
  6. echo "Please enter the name of the new DB password:"
  7. read -s NEW_PASS
  8. echo "Please re-enter the name of the new DB password:"
  9. read -s NEW_PASS_CONFIRM
  10.  
  11. if [ "$NEW_PASS" == "$NEW_PASS_CONFIRM" ]
  12. then
  13. echo "Creting new DB named $NEW_DB owned by $NEW_USER"
  14. echo "You will need the MySQL root password for this:"
  15. 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;"
  16. if [ $? -eq 0 ]
  17. then
  18. echo "Database sucessfully created!"
  19. fi
  20. else
  21. echo "Passwords do not match please try again"
  22. fi
Add Comment
Please, Sign In to add comment