You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: server/plugins-available/mysql_clientdb_plugin.inc.php
+31-20Lines changed: 31 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -150,16 +150,21 @@ function process_host_list($action, $database_name, $database_user, $database_pa
150
150
$link->query("CREATE USER '".$link->escape_string($database_user)."'@'$db_host'");
151
151
$app->log("CREATE USER '".$link->escape_string($database_user)."'@'$db_host'", LOGLEVEL_DEBUG);
152
152
153
-
// set the password
154
-
// MySQL < 5.7 and MariadB 10
155
-
if(!$link->query("UPDATE mysql.user SET `Password` = '".$link->escape_string($database_password)."' WHERE `Host` = '".$db_host."' AND `User` = '".$link->escape_string($database_user)."'")) {
$query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
156
+
$link->escape_string($database_user),
157
+
$db_host,
158
+
$link->escape_string($database_password));
159
+
if(!$link->query($query)) $success = false;
160
+
}
161
+
// mysql >= 5.7
162
+
else {
163
+
$query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s'",
164
+
$link->escape_string($database_user),
165
+
$db_host,
166
+
$link->escape_string($database_password));
167
+
if(!$link->query($query)) $success = false;
163
168
}
164
169
165
170
$app->log("PASSWORD SET FOR '".$link->escape_string($database_user)."'@'$db_host' success? " . ($success ? 'yes' : 'no'), LOGLEVEL_DEBUG);
@@ -182,15 +187,21 @@ function process_host_list($action, $database_name, $database_user, $database_pa
182
187
//if(!$link->query("SET PASSWORD FOR '".$link->escape_string($database_user)."'@'$db_host' = '".$link->escape_string($database_password)."'")) $success = false;
183
188
// SET PASSWORD for already hashed passwords is not supported by latest MySQL 5.7 anymore, so we have to set the hashed password directly
184
189
if(trim($database_password) != '') {
185
-
// MySQL < 5.7 and MariadB 10
186
-
if(!$link->query("UPDATE mysql.user SET `Password` = '".$link->escape_string($database_password)."' WHERE `Host` = '".$db_host."' AND `User` = '".$link->escape_string($database_user)."'")) {
0 commit comments