Commit b8533a60 authored by Timo Boldt's avatar Timo Boldt
Browse files

implemented mariadb

See issue #4321
parent 407bd7c1
...@@ -683,17 +683,31 @@ class mysql_clientdb_plugin { ...@@ -683,17 +683,31 @@ class mysql_clientdb_plugin {
$result = $app->db->queryOneRecord("SELECT VERSION() as version"); $result = $app->db->queryOneRecord("SELECT VERSION() as version");
$dbversion = $result['version']; $dbversion = $result['version'];
if (version_compare($dbversion, '5.7') >= 0) { // mariadb
$query = sprintf("ALTER USER IF EXISTS '%s'@'%s' IDENTIFIED WITH mysql_native_password AS '%s';", if(stripos($dbversion, 'mariadb') !== false) {
$link->escape_string($data['new']['database_user']), $query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
$db_host, $link->escape_string($data['new']['database_user']),
$link->escape_string($data['new']['database_password'])); $db_host,
$link->escape_string($data['new']['database_password']));
$link->query($query); $link->query($query);
} }
// mysql
else { else {
$link->query("SET PASSWORD FOR '".$link->escape_string($data['new']['database_user'])."'@'$db_host' = '".$link->escape_string($data['new']['database_password'])."';"); 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 {
$query = sprintf("SET PASSWORD FOR '%s'@'%s' = '%s'",
$link->escape_string($data['new']['database_user']),
$db_host,
$link->escape_string($data['new']['database_password']));
$link->query($query);
}
$app->log('Changing MySQL user password for: ' . $data['new']['database_user'] . '@' . $db_host, LOGLEVEL_DEBUG);
} }
$app->log('Changing MySQL user password for: '.$data['new']['database_user'].'@'.$db_host, LOGLEVEL_DEBUG);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment