Admin user only if MYSQL_ALLOW_EMPTY_PASSWORD

This commit is contained in:
Michael RICOIS 2018-03-28 10:35:50 +02:00
parent cdd3016af0
commit ccd3a9fe2a
4 changed files with 72 additions and 56 deletions

View File

@ -1,19 +1,23 @@
#!/bin/bash
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
if [ -n $MYSQL_ALLOW_EMPTY_PASSWORD ]; then
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
echo "=> Done!"
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MariaDB user 'root' has no password but only allows local connections"
echo "========================================================================"
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MariaDB user 'root' has no password but only allows local connections"
echo "========================================================================"
fi

View File

@ -1,19 +1,23 @@
#!/bin/bash
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
if [ -n $MYSQL_ALLOW_EMPTY_PASSWORD ]; then
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
echo "=> Done!"
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MariaDB user 'root' has no password but only allows local connections"
echo "========================================================================"
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MySQL user 'root' has no password but only allows local connections"
echo "========================================================================"
fi

View File

@ -1,19 +1,23 @@
#!/bin/bash
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
if [ -n $MYSQL_ALLOW_EMPTY_PASSWORD ]; then
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
echo "=> Done!"
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MariaDB user 'root' has no password but only allows local connections"
echo "========================================================================"
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MySQL user 'root' has no password but only allows local connections"
echo "========================================================================"
fi

View File

@ -1,19 +1,23 @@
#!/bin/bash
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
if [ -n $MYSQL_ALLOW_EMPTY_PASSWORD ]; then
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
PASS=${MYSQL_ADMIN_PASSWORD:-$(pwgen -s 12 1)}
_word=$( [ ${MYSQL_ADMIN_PASSWORD} ] && echo "preset" || echo "random" )
echo "=> Creating MariaDB admin user with ${_word} password"
echo "=> Done!"
mysql -uroot -e "CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED BY '$PASS'"
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MariaDB user 'root' has no password but only allows local connections"
echo "========================================================================"
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this MariaDB Server using:"
echo ""
echo " mysql -uadmin -p$PASS -h<host> -P<port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "MySQL user 'root' has no password but only allows local connections"
echo "========================================================================"
fi