Skip to content

Commit

Permalink
fix addons/mysqladmin_shell.sh in 123.09beta01
Browse files Browse the repository at this point in the history
Fix bug when using multidb mode in addons/mysqladmin_shell.sh if you list in dblist.txt different db username but same db username password for multiple entries, it would skip creating the db username https://community.centminmod.com/threads/mysqladmin_shell-sh-issue.14321/#post-61389. Fix allows to user different db username but same db username password for multiple entries.
  • Loading branch information
centminmod committed Mar 24, 2018
1 parent 88b31c5 commit cf9ee62
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions addons/mysqladmin_shell.sh
Expand Up @@ -139,6 +139,12 @@ if [[ "$rootset" = [yY] && -f "$dbfile" ]]; then
# mysql username
mysql ${MYSQLOPTS} -e "CREATE USER '$u'@'$MYSQLHOSTNAME' IDENTIFIED BY '$p';" >/dev/null 2>&1
USERCHECK=$?
elif [[ "$PREV_USER" != "$u" && "$PREV_PASS" = "$p" ]]; then
# if PREV_USER not equal to $u AND PREV_PASS equal to $p
# then it's not the same mysql username and pass so create the
# mysql username
mysql ${MYSQLOPTS} -e "CREATE USER '$u'@'$MYSQLHOSTNAME' IDENTIFIED BY '$p';" >/dev/null 2>&1
USERCHECK=$?
elif [[ "$PREV_USER" = "$u" && "$PREV_PASS" = "$p" ]]; then
# if PREV_USER equal to $u AND PREV_PASS equal to $p
# then it's same mysql username and pass so skip
Expand All @@ -163,6 +169,10 @@ if [[ "$rootset" = [yY] && -f "$dbfile" ]]; then
# then it's same mysql username and pass so add database
# to existing mysql user and pass
echo "GRANT index, select, insert, delete, update, create, drop, alter, create temporary tables, execute, lock tables, create view, show view, create routine, alter routine, trigger ON \`$db\`.* TO '$u'@'$MYSQLHOSTNAME'; flush privileges; show grants for '$u'@'$MYSQLHOSTNAME';" | mysql ${MYSQLOPTS} >/dev/null 2>&1
elif [[ "$PREV_USER" != "$u" && "$PREV_PASS" = "$p" ]]; then
# if PREV_USER not equal to $u AND PREV_PASS equal to $p
echo "GRANT index, select, insert, delete, update, create, drop, alter, create temporary tables, execute, lock tables, create view, show view, create routine, alter routine, trigger ON \`$db\`.* TO '$u'@'$MYSQLHOSTNAME'; flush privileges; show grants for '$u'@'$MYSQLHOSTNAME';" | mysql ${MYSQLOPTS} >/dev/null 2>&1
echo "$u $p" > /tmp/mysqladminshell_userpass.txt
else
# if PREV_USER not equal to $u AND PREV_PASS not equal to $p
echo "GRANT index, select, insert, delete, update, create, drop, alter, create temporary tables, execute, lock tables, create view, show view, create routine, alter routine, trigger ON \`$db\`.* TO '$u'@'$MYSQLHOSTNAME'; flush privileges; show grants for '$u'@'$MYSQLHOSTNAME';" | mysql ${MYSQLOPTS} >/dev/null 2>&1
Expand Down

0 comments on commit cf9ee62

Please sign in to comment.