[GH-ISSUE #44] A way to specify a non-standard socket? #30

Open
opened 2026-02-25 21:33:05 +03:00 by kerem · 1 comment
Owner

Originally created by @camateg on GitHub (Mar 28, 2017).
Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/44

Just a small feature request, but it wasn't clear how to use a non-standard socket. Something like this:

server1:
   user: root
   password: root
   port: 3306
   host: localhost 
   socket: /Applications/MAMP/tmp/mysql/mysql.sock
Originally created by @camateg on GitHub (Mar 28, 2017). Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/44 Just a small feature request, but it wasn't clear how to use a non-standard socket. Something like this: server1: user: root password: root port: 3306 host: localhost socket: /Applications/MAMP/tmp/mysql/mysql.sock
Author
Owner

@jasdeepkhalsa commented on GitHub (Nov 24, 2017):

Hi @camateg,

We'll add this to this list of feature requests - would also be good to know if your request is for personal or corporate use - as I've personally never needed to use a custom socket before. Just want to know a little bit more about your exact use case :)

In the meantime, you can achieve what you want by:

  • In an text editor / IDE navigate to src/DB/DBManager.php
  • Add the following line 'unix_socket' => '/path/to/custom/socket/mysql/mysql.sock' as part of $this->capsule->addConnection, just like as follows:
$this->capsule->addConnection([
                'driver'    => 'mysql',
                'host'      => $server['host'],
                'port'      => $server['port'],
                'database'  => $db,
                'username'  => $server['user'],
                'password'  => $server['password'],
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'unix_socket' => '/path/to/custom/socket/mysql/mysql.sock'
            ], $key);

Alternatively, you could do something like 'unix_socket' => getenv('UNIX_SOCKET'),

And then create/add to your .env file, as follows: UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

<!-- gh-comment-id:346866485 --> @jasdeepkhalsa commented on GitHub (Nov 24, 2017): Hi @camateg, We'll add this to this list of feature requests - would also be good to know if your request is for personal or corporate use - as I've personally never needed to use a custom socket before. Just want to know a little bit more about your exact use case :) In the meantime, you can achieve what you want by: * In an text editor / IDE navigate to `src/DB/DBManager.php` * Add the following line `'unix_socket' => '/path/to/custom/socket/mysql/mysql.sock'` as part of `$this->capsule->addConnection`, just like as follows: ```php $this->capsule->addConnection([ 'driver' => 'mysql', 'host' => $server['host'], 'port' => $server['port'], 'database' => $db, 'username' => $server['user'], 'password' => $server['password'], 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'unix_socket' => '/path/to/custom/socket/mysql/mysql.sock' ], $key); ``` Alternatively, you could do something like `'unix_socket' => getenv('UNIX_SOCKET'),` And then create/add to your `.env` file, as follows: `UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DBDiff#30
No description provided.