From eb0f5dda28b375f39d8b51e7247df760b5c9a36d Mon Sep 17 00:00:00 2001 From: Ze'ev Schurmann Date: Sun, 26 Nov 2023 08:26:34 +0200 Subject: [PATCH] added makedb.sh --- make-mysql-database/makedb.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 make-mysql-database/makedb.sh diff --git a/make-mysql-database/makedb.sh b/make-mysql-database/makedb.sh new file mode 100644 index 0000000..2408601 --- /dev/null +++ b/make-mysql-database/makedb.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [[ -z $1 ]] +then + echo -n "Name of Database: " + read dbname + echo -n "Name of User: " + read dbuser + echo -n "Password: " + read dbpass +else + dbname=$1 + dbuser=$2 + dbpass=$3 +fi + +echo "create database $dbname; create user $dbuser@localhost identified by '$dbpassword'; grant all privileges on $dbname.* to $dbuser@localhost; flush privileges;" | mysql + +echo "User $dbuser with password $dbpass assigned to database $dbname."