From d155c8e5fe500459884876046ccab5b2f28a4b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 7 Dec 2015 12:00:31 +0100 Subject: [PATCH] Add unix_socket support for mysql during initial installation - fixes #20210 --- lib/private/setup/mysql.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php index f2d2b15cd9..e8b88eb348 100644 --- a/lib/private/setup/mysql.php +++ b/lib/private/setup/mysql.php @@ -89,15 +89,28 @@ class MySQL extends AbstractDatabase { * @throws \OC\DatabaseSetupException */ private function connect() { - $type = 'mysql'; + $connectionParams = array( - 'host' => $this->dbHost, - 'user' => $this->dbUser, - 'password' => $this->dbPassword, - 'tablePrefix' => $this->tablePrefix, + 'host' => $this->dbHost, + 'user' => $this->dbUser, + 'password' => $this->dbPassword, + 'tablePrefix' => $this->tablePrefix, ); + + // adding port support + if (strpos($this->dbHost, ':')) { + // Host variable may carry a port or socket. + list($host, $portOrSocket) = explode(':', $this->dbHost, 2); + if (ctype_digit($portOrSocket)) { + $connectionParams['port'] = $portOrSocket; + } else { + $connectionParams['unix_socket'] = $portOrSocket; + } + $connectionParams['host'] = $host; + } + $cf = new ConnectionFactory(); - return $cf->getConnection($type, $connectionParams); + return $cf->getConnection('mysql', $connectionParams); } /**