Skip to content

Instantly share code, notes, and snippets.

@mohanarpit
Created May 30, 2013 04:27
Show Gist options
  • Save mohanarpit/5675714 to your computer and use it in GitHub Desktop.
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.
#!/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