How to configure mysql database connection with a different socket
According to this Drupal issue, setting the socket in the UI is just not possible right now: (at least in 8.6.10)

https://www.drupal.org/project/drupal/issues/793200

I also could not figure out how to set the socket in sites/default/settings.php.

I had to resort to hardcoding my socket in this file:

core/lib/Drupal/Core/Database/Driver/mysql/Connection.php


This block of code:

    // The DSN should use either a socket or a host/port.
    if (isset($connection_options['unix_socket'])) {
      $dsn = 'mysql:unix_socket=' . $connection_options['unix_socket'];
    }
    else {
      // Default to TCP connection on port 3306.
      $dsn = 'mysql:host=' . $connection_options['host'] . ';port=' . (empty($connection_options['port']) ? 3306 : $connection_options['port']);
    }


I could not find any way to set "unix_socket" value on $connection_options, so I resorted to hardcoding it before this block like:

$connection_options['unix_socket'] = '/path/to/my/mysql/socket';