Last active
July 29, 2016 10:11
-
-
Save bekce/f5a24f56875afb572768222d26a1e362 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
| if [ $# -ne 4 ] | |
| then | |
| echo "Usage: <new-db-name> <new-user> <new-pass> <root-pass>" | |
| exit 1 | |
| fi | |
| dbname=$1 | |
| newuser=$2 | |
| newpass=$3 | |
| rootpass=$4 | |
| mysql -uroot -p$rootpass<<EOF | |
| CREATE DATABASE IF NOT EXISTS $dbname CHARACTER SET utf8 COLLATE utf8_general_ci; | |
| GRANT USAGE ON * . * TO '$newuser'@'localhost' IDENTIFIED BY '$newpass' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; | |
| GRANT ALL PRIVILEGES ON $dbname . * TO '$newuser'@'localhost'; | |
| EOF | |
| echo "database $dbname created, user $newuser with pass $newpass is granted permission" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment