diff options
author | Joas Schilling <coding@schilljs.com> | 2020-02-05 10:05:11 +0100 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2020-02-06 18:39:08 +0000 |
commit | ecc4bb5666969afe5f3204656ba6ba633c4dfb4d (patch) | |
tree | a251716117e2fa10c69d5cb74f1bbe3518b03279 | |
parent | 55ccfef48e46616b40d0c2bd3fb1f46faefca93c (diff) | |
download | nextcloud-server-ecc4bb5666969afe5f3204656ba6ba633c4dfb4d.tar.gz nextcloud-server-ecc4bb5666969afe5f3204656ba6ba633c4dfb4d.zip |
Only provide the auth method for MySQL 8.0+ to not break MariaDB
Provide the auth method for MySQL 8.0+
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/Setup/MySQL.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php index 3bb940186f8..4bcf6818f0e 100644 --- a/lib/private/Setup/MySQL.php +++ b/lib/private/Setup/MySQL.php @@ -32,6 +32,7 @@ namespace OC\Setup; use OC\DB\MySqlTools; use OCP\IDBConnection; use OCP\ILogger; +use Doctrine\DBAL\Platforms\MySQL80Platform; class MySQL extends AbstractDatabase { public $dbprettyname = 'MySQL/MariaDB'; @@ -100,10 +101,18 @@ class MySQL extends AbstractDatabase { $password = $this->dbPassword; // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one, // the anonymous user would take precedence when there is one. - $query = "CREATE USER '$name'@'localhost' IDENTIFIED WITH mysql_native_password BY '$password'"; - $connection->executeUpdate($query); - $query = "CREATE USER '$name'@'%' IDENTIFIED WITH mysql_native_password BY '$password'"; - $connection->executeUpdate($query); + + if ($connection->getDatabasePlatform() instanceof Mysql80Platform) { + $query = "CREATE USER '$name'@'localhost' IDENTIFIED WITH mysql_native_password BY '$password'"; + $connection->executeUpdate($query); + $query = "CREATE USER '$name'@'%' IDENTIFIED WITH mysql_native_password BY '$password'"; + $connection->executeUpdate($query); + } else { + $query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'"; + $connection->executeUpdate($query); + $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; + $connection->executeUpdate($query); + } } catch (\Exception $ex){ $this->logger->logException($ex, [ |