Skip to content

Commit 7e41652

Browse files
author
Till Brehm
committed
Fixed #4409 Password of MySQL users does not get updated on MySQL 5.7 servers
1 parent c638acc commit 7e41652

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/plugins-available/mysql_clientdb_plugin.inc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ function process_host_list($action, $database_name, $database_user, $database_pa
143143
if(!$link->query("RENAME USER '".$link->escape_string($database_user)."'@'$db_host' TO '".$link->escape_string($database_rename_user)."'@'$db_host'")) $success = false;
144144
} elseif($action == 'PASSWORD') {
145145
//if(!$link->query("SET PASSWORD FOR '".$link->escape_string($database_user)."'@'$db_host' = '".$link->escape_string($database_password)."'")) $success = false;
146-
// SET PASSWORD for already hashed passwords is not supported by latest MySQL 5.7 anymore, so we set it directly
146+
// SET PASSWORD for already hashed passwords is not supported by latest MySQL 5.7 anymore, so we have to set the hashed password directly
147147
if(trim($database_password) != '') {
148-
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;
148+
// MySQL < 5.7 and MariadB 10
149+
if(!$link->query("UPDATE mysql.user SET `Password` = '".$link->escape_string($database_password)."' WHERE `Host` = '".$db_host."' AND `User` = '".$link->escape_string($database_user)."'")) {
150+
// MySQL 5.7, the Password field has been renamed to authentication_string
151+
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;
152+
}
149153
if($success == true) $link->query("FLUSH PRIVILEGES");
150154
}
151155
}

0 commit comments

Comments
 (0)