Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-02-05 12:05:11 +0300
committerJoas Schilling <coding@schilljs.com>2020-02-05 15:54:57 +0300
commit0aa216fc483cb86eadd0f1e759406e4d679c949c (patch)
tree67ee0e182c75ce94de0f8d15038b0b07a96c8b64 /lib/private/Setup/MySQL.php
parent23fc654fc4d2122dc71ddf3b8e43fd7124555cff (diff)
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>
Diffstat (limited to 'lib/private/Setup/MySQL.php')
-rw-r--r--lib/private/Setup/MySQL.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index 3f4dd616a2f..1ee650fecc6 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -34,6 +34,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';
@@ -102,10 +103,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, [