Upload files to ''
Added bash script
This commit is contained in:
37
sql_datauser.sh
Normal file
37
sql_datauser.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
# sql_datauser.sh
|
||||
# ---------------
|
||||
#
|
||||
# Very basic script to create a database on mysql whit its own user
|
||||
# and password to be used by an application like a website,
|
||||
# cloud, etc.
|
||||
# As of the date below it has only been tested on mariaDB sql server.
|
||||
#
|
||||
# by Jony Silva
|
||||
# Wed 14 Nov 11:53:12 GMT 2018
|
||||
# Anti-copyright and/or BeerWare.
|
||||
|
||||
#!/usr/bin/env bash
|
||||
message1="Creating database, user and password for new application."
|
||||
message2="Give me DataBase user:"
|
||||
message3="Give me DataBase user password:"
|
||||
message4="Give me DataBase name:"
|
||||
message5="Give me host(press enter for default\"localhost\"):"
|
||||
|
||||
echo $message1
|
||||
echo $message4
|
||||
read newDb
|
||||
echo $message2
|
||||
read newUser
|
||||
echo $message3
|
||||
read newDbPassword
|
||||
echo $message5
|
||||
read host
|
||||
|
||||
|
||||
if [ -z "$host" ]
|
||||
then host=localhost
|
||||
fi
|
||||
|
||||
commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.* TO '${newUser}'@'${host}';FLUSH PRIVILEGES;"
|
||||
|
||||
echo "${commands}" | /usr/bin/mysql -u root -p
|
Reference in New Issue
Block a user