]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only provide the auth method for MySQL 8.0+ to not break MariaDB
authorJoas Schilling <coding@schilljs.com>
Wed, 5 Feb 2020 09:05:11 +0000 (10:05 +0100)
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Tue, 14 Apr 2020 09:02:14 +0000 (11:02 +0200)
Provide the auth method for MySQL 8.0+

Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Setup/MySQL.php

index b66af448b446b70de915d2650f749742ec30f8f2..964f16f3711dc8e4db2c8a171eea76153c8e51bf 100644 (file)
@@ -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, [