Add create mysql user and database

This commit is contained in:
mirivlad 2024-02-28 13:54:31 +08:00
parent f741686510
commit 6772a21002
1 changed files with 15 additions and 0 deletions

15
create_db.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
echo -n "DB_User: "
read USER
echo -n "DB_Pass: "
read PASS
echo -n "DB_Name: "
read DB
mysql <<MY_QUERY
USE mysql;
CREATE DATABASE $DB character set utf8mb4 collate utf8mb4_bin;
CREATE USER '$USER'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $DB.* TO '$USER'@'localhost';
FLUSH PRIVILEGES;
MY_QUERY