Skip to content

Instantly share code, notes, and snippets.

@rojenzaman
Created July 9, 2020 17:10
Show Gist options
  • Save rojenzaman/f1fbd1311b4089920c7a28b113fd87e7 to your computer and use it in GitHub Desktop.
Save rojenzaman/f1fbd1311b4089920c7a28b113fd87e7 to your computer and use it in GitHub Desktop.
Wordpress Database Creator
#!/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
@rojenzaman
Copy link
Author

Usage

wdb-create.sh <db name> <db user> <ip> <db password> [sql]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment