MySQL Connection Errors After Mac OS X Update

It appears that my local development environment was no longer able to establish a database connnection after a Mac OS X system update. All my Symphony CMS sites stopped working.

I would receive errors like this:

              Symphony Database Error
There was a problem whilst attempting to establish a database connection.
Please check all connection information is correct.
The following error was returned.
2002: No such file or directory


I was also unable to connect to my databases through phpMyAdmin.

Since I’m just running this on my localhost, I’m not too concerned about security. So, my phpMyAdmin configuration file looked like this:

$cfg['blowfish_secret']                = 'helloblowfish';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['user']            = 'root';
$cfg['Servers'][$i]['password']        = '';
$cfg['Servers'][$i]['auth_type']       = 'config';


I new that MySQL was running and I was able to access it on the command line without any problem.

              mysql -u root
show databases;


So, it had to be a configuration issue. It turns out this was what I was missing for the phpMyAdmin configuration:

              $cfg['Servers'][$i]['socket']          = '/tmp/mysql.sock';


None of my local development sites were able to connect to the MySQL server. Gabriel de Kadt was experiencing the same issue: Got an “Error establishing a database connection” in Mac OS X 10.6?. This common error arises from changes to the default location of the MySQL socket.

I used TextWrangler, configured with command line tools, to edit the PHP configuration file by opening a terminal window and typing:

              edit /etc/php.ini


I found the line to configure the path for the default MySQL socket

              mysql.default_socket =


And changed it to

              mysql.default_socket = /tmp/mysql.sock


Then, restart the server

              sudo apachectl graceful


Now, I’m back up and running again.