Use a Unix Socket Between Drupal 7 and MariaDB.

It's not immediately obvious how to do it, but connecting to your database from Drupal can be speeded up by using a unix socket. First though, you have to install Drupal using a TCP socket. Standard database installations listen on localhost so the install should proceed without problem.

Once this is done, edit settings.php so:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'database_name',
      'username' => 'user_name',
      'password' => 'password',
#      'host' => 'localhost',
#      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
Now communications are through the much faster unix socket, rather than via TCP.