Skip to content

Commit 84bb2df

Browse files
committed
Support connection via socket
If the port is given we use tcp protocol, otherwise we assume a socket is available.
1 parent 13d1ec4 commit 84bb2df

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Service/AbstractDatabase.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,18 @@ private static function getMysqlArgs(): string
103103
$username = $dbConfig['user'];
104104
$database = $dbConfig['dbname'];
105105
$password = $dbConfig['password'];
106-
$port = $dbConfig['port'] ?? 3306;
106+
$port = $dbConfig['port'] ?? null;
107+
108+
if ($port) {
109+
$port = "--protocol tcp --port=$port";
110+
} else {
111+
$port = '--protocol socket';
112+
}
107113

108114
// It's possible to have no password at all
109115
$password = $password ? '-p' . $password : '';
110116

111-
return "--user=$username $password --host=$host --protocol tcp --port=$port $database";
117+
return "--user=$username $password --host=$host $port $database";
112118
}
113119

114120
final public static function loadRemoteData(string $remote): void

0 commit comments

Comments
 (0)