Skip to content

Commit b8533a6

Browse files
author
Timo Boldt
committed
implemented mariadb
See issue #4321
1 parent 407bd7c commit b8533a6

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

server/plugins-available/mysql_clientdb_plugin.inc.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,17 +683,31 @@ function db_user_update($event_name, $data) {
683683
$result = $app->db->queryOneRecord("SELECT VERSION() as version");
684684
$dbversion = $result['version'];
685685

686-
if (version_compare($dbversion, '5.7') >= 0) {
687-
$query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s';",
688-
$link->escape_string($data['new']['database_user']),
689-
$db_host,
690-
$link->escape_string($data['new']['database_password']));
686+
// mariadb
687+
if(stripos($dbversion, 'mariadb') !== false) {
688+
$query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
689+
$link->escape_string($data['new']['database_user']),
690+
$db_host,
691+
$link->escape_string($data['new']['database_password']));
691692
$link->query($query);
692693
}
694+
// mysql
693695
else {
694-
$link->query("SET PASSWORD FOR '".$link->escape_string($data['new']['database_user'])."'@'$db_host' = '".$link->escape_string($data['new']['database_password'])."';");
696+
if (version_compare($dbversion, '5.7') >= 0) {
697+
$query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s'",
698+
$link->escape_string($data['new']['database_user']),
699+
$db_host,
700+
$link->escape_string($data['new']['database_password']));
701+
$link->query($query);
702+
} else {
703+
$query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
704+
$link->escape_string($data['new']['database_user']),
705+
$db_host,
706+
$link->escape_string($data['new']['database_password']));
707+
$link->query($query);
708+
}
709+
$app->log('Changing MySQL user password for: ' . $data['new']['database_user'] . '@' . $db_host, LOGLEVEL_DEBUG);
695710
}
696-
$app->log('Changing MySQL user password for: '.$data['new']['database_user'].'@'.$db_host, LOGLEVEL_DEBUG);
697711
}
698712
}
699713

0 commit comments

Comments
 (0)