diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-10 10:13:49 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-10 10:13:49 +0100 |
commit | 9f4ceef7c9230c0f7e453e6345f59923a54c40ed (patch) | |
tree | 0b2b2b74647cb34675e933d8aee241bd5be8414d /lib | |
parent | 292a70245213627391111725e4fc499f4d75c7e0 (diff) | |
parent | d155c8e5fe500459884876046ccab5b2f28a4b43 (diff) | |
download | nextcloud-server-9f4ceef7c9230c0f7e453e6345f59923a54c40ed.tar.gz nextcloud-server-9f4ceef7c9230c0f7e453e6345f59923a54c40ed.zip |
Merge pull request #20984 from owncloud/fix-mysql-setup-unix-socket-master
Add unix_socket support for mysql during initial installation - fixes…
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/setup/mysql.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php index f2d2b15cd90..e8b88eb3489 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); } /** |