Merge pull request #20984 from owncloud/fix-mysql-setup-unix-socket-master

Add unix_socket support for mysql during initial installation - fixes…
This commit is contained in:
Thomas Müller 2015-12-10 10:13:49 +01:00
commit 9f4ceef7c9
1 changed files with 19 additions and 6 deletions

View File

@ -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,
);
// 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);
}
/**