• 4

I'm getting errors whenever I try to connect locally to mySQL on Mac OS Snow Leopard 10.6.4. I'm running mySQL 5.1.46. I can log in using the console. I'm running PHP 5.3.2 and my phpinfo()page is working fine. So I've got PHP running, I can log into the mySQL server using both the console and Sequel Pro.

So I suspected that it was a socket issue. In my /etc directory, I don't have php.ini, I have php.ini.default. So I go in there, and every place I see "default_socket" I change it from:




I see it in the following locations:

mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

And when I go to connect to phpMyAdmin, I get the following error: Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.

And when I look in my phpinfo() file, I get the following under mySQL:

mysql.default_socket /var/mysql/mysql.sock /var/mysql/mysql.sock

I restart Apache... heck, I restart the whole computer. Still, nothing. I know mySQL is working, I know PHP is working, but I can't get them talking.

Any help?

Bring the mysql.sock to PHP

One problem that has come about with MySQL and Leopard is the location of the mysql.sock file. Previously, the default location for this file was in the /tmp directory. That location has now moved to the /var/mysql directory. PHP will look for it there. Unfortunately, the default location from the MySQL will still place it in the old location. We can fix this by creating a my.cnf configuration file in the /etc directory. Save a file with the following contents to /etc/my.cnf:

[client] socket = /var/mysql/mysql.sock

[mysqld] socket = /var/mysql/mysql.sock

In the terminal window, type the following commands to create the directory for the sock file:

sudo mkdir /var/mysql sudo chown _mysql /var/mysql


  • 0
Reply Report

If you don't want to muck about with config settings for either mysql or php, then set up this hack:

mkdir /var/mysql

ln -s /tmp/mysql.sock /var/mysql/mysql.sock

This creates an alias in the location that PHP is looking for that connects to the real mysql.sock.

  • 0
Reply Report