Skip to content

Commit c8667c4

Browse files
author
Till Brehm
committed
Fixed #4191 Updating database user password on MySQL 5.7 leads to "double hash"
How to reproduce issue
1 parent f66b638 commit c8667c4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/plugins-available/mysql_clientdb_plugin.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ function process_host_list($action, $database_name, $database_user, $database_pa
140140
} elseif($action == 'RENAME') {
141141
if(!$link->query("RENAME USER '".$link->escape_string($database_user)."'@'$db_host' TO '".$link->escape_string($database_rename_user)."'@'$db_host'")) $success = false;
142142
} elseif($action == 'PASSWORD') {
143-
if(!$link->query("SET PASSWORD FOR '".$link->escape_string($database_user)."'@'$db_host' = '".$link->escape_string($database_password)."'")) $success = false;
143+
//if(!$link->query("SET PASSWORD FOR '".$link->escape_string($database_user)."'@'$db_host' = '".$link->escape_string($database_password)."'")) $success = false;
144+
// SET PASSWORD for already hashed passwords is not supported by latest MySQL 5.7 anymore, so we set it directly
145+
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;
146+
if($success == true) $link->query("FLUSH PRIVILEGES");
144147
}
145148
}
146149

0 commit comments

Comments
 (0)