Add 'createmysql.sh'

This commit is contained in:
2021-10-28 23:18:19 +00:00
parent 51f54d32af
commit 8c40c8759b
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
mkdir ~/.librography
touch ~/.librography/
echo "Enter the user name for database: "
read password
echo "The Current User Name is $first_name"
echo
echo "Enter other users'names: "
read name1 name2 name3
echo "$name1, $name2, $name3 are the other users."
PASS=`pwgen -s 40 1`
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
FLUSH PRIVILEGES;
MYSQL_SCRIPT
echo "MySQL user created."
echo "Username: $1"
echo "Password: $PASS"