Fix for mysql 5.7 when reset password

Whit mysql 5.7 when reset password db.conf not get updated because cant get new md5 hash

This will fix it

I not touch GRANT ALL queryes because all working fine whit that part and all passwords was changed, but maybe you want change it.
I see this bug may afect this function:

dump_mysql_database() 

But I not know fot what is used grep -v "Grants for" > $grants

So I not touch it because not know how test it :)
This commit is contained in:
Skamasle 2016-12-09 20:42:27 +01:00 committed by GitHub
commit c1cbbd3eb4

View file

@ -264,9 +264,14 @@ change_mysql_password() {
IDENTIFIED BY '$dbpass'"
mysql_query "$query" > /dev/null
query="SHOW GRANTS FOR '$DBUSER'"
md5=$(mysql_query "$query" 2>/dev/null)
md5=$(echo "$md5" |grep 'PASSWORD' |tr ' ' '\n' |tail -n1 |cut -f 2 -d \')
if [ "$(echo $mysql_ver |cut -d '.' -f2)" -ge 7 ]; then
md5=$(mysql_query "SHOW CREATE USER \`$DBUSER\`" 2>/dev/null)
md5=$(echo "$md5" |grep password |cut -f8 -d \')
else
md5=$(mysql_query "SHOW GRANTS FOR \`$DBUSER\`" 2>/dev/null)
md5=$(echo "$md5" |grep PASSW|tr ' ' '\n' |tail -n1 |cut -f 2 -d \')
fi
}
# Change PostgreSQL database password