From 407bd7c17841d0e6ab4a425c46368d78bbf301cc Mon Sep 17 00:00:00 2001 From: Timo Boldt <timo.boldt@technobase.fm> Date: Thu, 23 Feb 2017 16:58:07 +0100 Subject: [PATCH] fixed mysql password update on mysql > 5.7 See issue #4321 --- .../mysql_clientdb_plugin.inc.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/plugins-available/mysql_clientdb_plugin.inc.php b/server/plugins-available/mysql_clientdb_plugin.inc.php index 8b04844e22..24cad9a871 100644 --- a/server/plugins-available/mysql_clientdb_plugin.inc.php +++ b/server/plugins-available/mysql_clientdb_plugin.inc.php @@ -680,7 +680,19 @@ class mysql_clientdb_plugin { } if($data['new']['database_password'] != $data['old']['database_password'] && $data['new']['database_password'] != '') { - $link->query("SET PASSWORD FOR '".$link->escape_string($data['new']['database_user'])."'@'$db_host' = '".$link->escape_string($data['new']['database_password'])."';"); + $result = $app->db->queryOneRecord("SELECT VERSION() as version"); + $dbversion = $result['version']; + + if (version_compare($dbversion, '5.7') >= 0) { + $query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s';", + $link->escape_string($data['new']['database_user']), + $db_host, + $link->escape_string($data['new']['database_password'])); + $link->query($query); + } + else { + $link->query("SET PASSWORD FOR '".$link->escape_string($data['new']['database_user'])."'@'$db_host' = '".$link->escape_string($data['new']['database_password'])."';"); + } $app->log('Changing MySQL user password for: '.$data['new']['database_user'].'@'.$db_host, LOGLEVEL_DEBUG); } } -- GitLab