Created
February 27, 2019 07:54
-
-
Save seraphyn/1e1f5c02fc3c2b4b119ca946952a42f4 to your computer and use it in GitHub Desktop.
Script for simple creation of an user including database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PASS=`pwgen -s 40 1` | |
USER=`pwgen -B 10 1` | |
mysql -uroot <<MYSQL_SCRIPT | |
CREATE DATABASE $USER; | |
CREATE USER '$USER'@'localhost' IDENTIFIED BY '$PASS'; | |
GRANT ALL PRIVILEGES ON $USER.* TO '$USER'@'localhost'; | |
FLUSH PRIVILEGES; | |
MYSQL_SCRIPT | |
echo "MySQL user created." | |
echo "Username: $USER" | |
echo "Password: $PASS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment