Added mysql script
This commit is contained in:
parent
336aa7f027
commit
75229978c0
1 changed files with 13 additions and 0 deletions
13
create-mysql.sh
Normal file
13
create-mysql.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script creates an user and a database with the same name, with a password, only for localhost.
|
||||
echo MySQL root password:
|
||||
read -s rootPassword
|
||||
echo Name:
|
||||
read name
|
||||
echo Password for ${name}:
|
||||
read -s password
|
||||
mysql -u root -p${rootPassword} -e "CREATE USER '${name}'@'localhost' IDENTIFIED BY '${password}';"
|
||||
mysql -u root -p${rootPassword} -e "CREATE DATABASE ${name};"
|
||||
mysql -u root -p${rootPassword} -e "GRANT ALL PRIVILEGES ON ${name}.* TO '${name}'@'localhost';"
|
||||
mysql -u root -p${rootPassword} -e "FLUSH PRIVILEGES;"
|
Reference in a new issue