Mysql changes on Tiger 10.4.4

Posted Saturday, February 25th, 2006 at 11:46 am by Richard in the stuff category.

If you, like me, run PHP and mySQL on your Mac, you may have had problems with MySQL after the 10.4.4 or 10.4.5 upgrades.

I first noticed this when I could not use phpMyAdmin to connect ot mySQL, even though mySQL was running fine. The problem was reported as…

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2).

After much searching it turns out the socket that PHP is trying to use to connect to mySQL has moved. The socket is no longer in /var/mysql/mysql.sock, instead is resides in /tmp/mysql.sock.

There appear to be two solutions.

The first option is to add a line to your php.ini file telling it the location of the socket.

You’ll need to edit /etc/php.ini. If it doesn’t exist then copy the default one at /etc/php.ini.default

sudo cp /etc/php.ini.default /etc/php.ini

When you’ve done this edit the file

sudo vi /etc/php.ini

look for the line “mysql.default_socket = ” and change it to read…

mysql.default_socket = /tmp/mysql.sock

Done, now save it and restart apache

sudo apachectl graceful

Alternatively you can create a symbolic link to point the old socket to the new one eg

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

You may find the /var/mysql folder does not exists so you need to create it first…

sudo mkdir /var/mysql

This seems to work for me, technically incompetent as I am!

And if you want to get started with mySQL on your Mac grab the latest copy fromhere, just scroll down the page to the Mac section . It comes with a preference pane to start and stop it, but the mySQL Administrator is great so grab that too.

Comments...

Matt says... [toggle display]

Hi,
I had a problem with my wordpress blog (served from my G5 at home) after upgrading to 10.4.5 I followed option 1 from above and now it is all up and running smoothly again, thanks for the tips.

Matt.

 
Richard says... [toggle display]

Hi Matt, glad it worked for you.