Drupal 7 and MySQL sockets

28 March, 2024

I recently switched from a mysql.com implementation of MySQL to MacPorts on my local, and the Drupal sites would no longer load.

The MacPorts my.cnf file turns off networking, so that multiple versions of MySQL can be run. In doing so, one must then use socket files to access MySQL instead of TCP/IP. This requires a change to the database config in the settings.php file.

Simply add the path to your socket file as an additional line in the database config array, as follows:

'unix_socket' => '/<path>/mysqld.sock'

replacing <path> with the path on your system. On mine, it's:

/opt/local/var/run/mysql55/mysqld.sock

Login or Register to Comment!