Commit 7e416522 authored by Till Brehm's avatar Till Brehm

Fixed #4409 Password of MySQL users does not get updated on MySQL 5.7 servers

parent c638acc8
......@@ -143,9 +143,13 @@ class mysql_clientdb_plugin {
if(!$link->query("RENAME USER '".$link->escape_string($database_user)."'@'$db_host' TO '".$link->escape_string($database_rename_user)."'@'$db_host'")) $success = false;
} elseif($action == 'PASSWORD') {
//if(!$link->query("SET PASSWORD FOR '".$link->escape_string($database_user)."'@'$db_host' = '".$link->escape_string($database_password)."'")) $success = false;
// SET PASSWORD for already hashed passwords is not supported by latest MySQL 5.7 anymore, so we set it directly
// SET PASSWORD for already hashed passwords is not supported by latest MySQL 5.7 anymore, so we have to set the hashed password directly
if(trim($database_password) != '') {
if(!$link->query("UPDATE mysql.user SET `Password` = '".$link->escape_string($database_password)."' WHERE `Host` = '".$db_host."' AND `User` = '".$link->escape_string($database_user)."'")) $success = false;
// MySQL < 5.7 and MariadB 10
if(!$link->query("UPDATE mysql.user SET `Password` = '".$link->escape_string($database_password)."' WHERE `Host` = '".$db_host."' AND `User` = '".$link->escape_string($database_user)."'")) {
// MySQL 5.7, the Password field has been renamed to authentication_string
if(!$link->query("UPDATE mysql.user SET `authentication_string` = '".$link->escape_string($database_password)."' WHERE `Host` = '".$db_host."' AND `User` = '".$link->escape_string($database_user)."'")) $success = false;
}
if($success == true) $link->query("FLUSH PRIVILEGES");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment