Created
July 9, 2020 17:10
-
-
Save rojenzaman/f1fbd1311b4089920c7a28b113fd87e7 to your computer and use it in GitHub Desktop.
Wordpress Database Creator
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 | |
if [ "$#" -lt 4 ]; then | |
echo "`basename $0` <db name> <db user> <ip> <db password> [sql]"; | |
exit 1; | |
fi | |
mysql <<EOF | |
CREATE DATABASE $1; | |
CREATE USER $2@localhost IDENTIFIED BY '$4'; | |
GRANT ALL PRIVILEGES ON $1.* TO $2@localhost identified by '$4'; | |
CREATE USER $2@$3 IDENTIFIED BY '$4'; | |
GRANT ALL PRIVILEGES ON $1.* TO $2@$3 identified by '$4'; | |
FLUSH PRIVILEGES; | |
EOF | |
if [ "$#" -gt 3 ]; then | |
echo importing /w user:$2 | |
mysql -u $2 -p $1 < $5 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
wdb-create.sh <db name> <db user> <ip> <db password> [sql]