Created
May 30, 2013 04:27
-
-
Save mohanarpit/5675714 to your computer and use it in GitHub Desktop.
This script creates a new database and a user. Useful when setting up a project.
This file contains 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 | |
#This script creates a new DB and an associated user with it | |
echo "Input the database to be created: " | |
read db | |
echo "Input the username to be associated with the DB: " | |
read username | |
echo "Input the host (% for all the hosts): " | |
read host | |
echo "Input the password for the user: " | |
read pwd | |
mysql -u <ROOT USERNAME> -p<ROOT PASSWORD> << HERE | |
create database $db ; | |
create user '$username'@'$host' identified by '$pwd'; | |
grant all on $db.* to '$username'@'$host'; | |
flush privileges; | |
HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment