Created
July 19, 2020 08:16
-
-
Save arzzen/fa31706c337f27d609576dfdc7289c5a to your computer and use it in GitHub Desktop.
mysql_create_newuser_newdb.sh
This file contains hidden or 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 | |
newUser='testuser' | |
newDbPassword='testpwd' | |
newDb='testdb' | |
host=localhost | |
#host='%' | |
commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.* | |
TO '${newUser}'@'${host}';FLUSH PRIVILEGES;" | |
echo "${commands}" | /usr/bin/mysql -u root -p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment