Created
October 4, 2021 11:54
-
-
Save tsuyo/88de5391f94c2249ba5d463302047596 to your computer and use it in GitHub Desktop.
Create a MySQL Database
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
usage() { | |
echo "Usage: $0 <DB_NAME> <DB_USER> <DB_PASSWORD>" | |
exit | |
} | |
DB_NAME=$1 | |
DB_USER=$2 | |
DB_PASSWORD=$3 | |
[ -z "${DB_NAME}" -o -z "${DB_USER}" -o -z "${DB_PASSWORD}" ] && usage | |
mysql -u root -p << EOF | |
drop database if exists ${DB_NAME}; | |
create database ${DB_NAME} character set 'utf8'; | |
use ${DB_NAME}; | |
grant all on ${DB_NAME}.* to ${DB_USER}@localhost identified by '${DB_PASSWORD}'; | |
flush privileges; | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment