Skip to content

Firefly III: a personal finances manager

Add support for DSN

James Cole0bcc3240b7a7
diff --git a/.env.example b/.env.example
index 54df38589a..d004ff9dfd 100644
--- a/.env.example
+++ b/.env.example
@@ -69,6 +69,8 @@ DB_PORT=3306
DB_DATABASE=firefly
DB_USERNAME=firefly
DB_PASSWORD=secret_firefly_password
+# leave empty or omit when not using a socket connection
+DB_SOCKET=
# MySQL supports SSL. You can configure it here.
# If you use Docker or similar, you can set these variables from a file by appending them with _FILE
diff --git a/app/Console/Commands/CreateDatabase.php b/app/Console/Commands/CreateDatabase.php
index aa4a9092d9..b96a070556 100644
--- a/app/Console/Commands/CreateDatabase.php
+++ b/app/Console/Commands/CreateDatabase.php
@@ -63,6 +63,12 @@ class CreateDatabase extends Command
$exists = false;
$checked = false; // checked for existence of DB?
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
+
+ if ('' !== env('DB_SOCKET', '')) {
+ $dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', env('DB_SOCKET', ''));
+ }
+ $this->info(sprintf('DSN is %s', $dsn));
+
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,