Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cd /var/lib/mysql
- echo "Enter database name"
- read dirname
- if [ ! -d "$dirname" ]
- then
- echo "Database doesn't exist, Will Create new database"
- else
- echo "Database already exists enter different database name"
- echo "Enter database name"
- read dirname
- if [ ! -d "$dirname" ]
- then
- echo "Database doesn't exist, Will Create new database"
- else
- return
- fi
- fi
- read -p "Enter databse username : " username
- read -s -p "Enter database password : " password
- mysql -uroot -ppassword -e "create database $dirname;"
- mysql -uroot -ppassword -e "grant all on $dirname.* to '$username'@'localhost' identified by '$password';"
- mysql -uroot -ppassword -e "flush privileges;"
Add Comment
Please, Sign In to add comment