I'm not looking for the "use" solution. I want to run the site on my local development environment and use the unix socket to connect to the database. In my settings file I've set the host to 'host' => 'localhost', and I've tried 'unix_socket' => '/tmp/mysql.socket', as well, but both result in a PDOException: SQLSTATE[HY000] [2002] error in the apache logs.

When I connect directly to mysql through the command line I connect through the unix socket, but when I run it through Drupal it only connects through the TCP connection. I am under the impression Drupal will connect through the socket if the localhost host name is used, but this doesn't appear to be the case here.

Perhaps there's some other local configuration I'm missing.

1 Answer 1


I quickly figured this out after posting. To connect using a socket use 'unix_socket' => '/tmp/mysql.sock', not .socket.

This allows me to connect to mysql using the unix socket instead of the networking IP address, This may be an issue with core since I think by default Drupal should connect on this default socket.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.