How to fix Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'
Apparently, OS X Tiger doesn't allow for PHP MySQL connection out of the box. You get this:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'
I found the most clear fix here:
/etc/php.ini(.default) looks for mysql.sock in the wrong place... two options are to make a symbolic link from the right place to the socket...
sudo mkdir /var/mysql
sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
Or you can update your php.ini (.default) by finding "mysql.default_socket" and setting it to equal /private/tmp/mysql.sock and then restart apache with "apachectl graceful"
Technorati Tags: mysql, OS X, OS X Tiger, php

You are my new best friend. Thank you so much! (I'm gonna go click on some of your ads now.)
Posted by: beck | Jan 20, 2007 at 10:41 AM
This solution worked for me as well!
Thank you very much.
-Rich
Posted by: Richard Vincent | Feb 19, 2007 at 12:20 PM
hey i have this problem
Warning: mysql_pconnect(): Lost connection to MySQL server during query in C:\Websites\ratedesi\include\connectdb.php on line 6
Lost connection to MySQL server during query
how do i fix this
Posted by: tahir | Apr 04, 2007 at 05:00 PM
thank you, thank you and thank you!!
wordpress is finally working for me, yippee! suddenly the sun is shining brighter:)
cheers,
Bindu
Posted by: Bindu | Apr 02, 2008 at 07:34 AM
thank you so much!
Posted by: renee | Aug 10, 2008 at 05:06 AM
Lifesaver! Thanks very much for sharing this info!
Posted by: Ben | Sep 01, 2008 at 05:00 PM
cool...this really works for me....thank u soo much
Posted by: Pradeep | Sep 09, 2008 at 09:38 PM
FYI: This issue also occurs with Leopard. I applied the same solution as you suggested for Tiger and it worked great! Thank you.
Posted by: SDK | Nov 08, 2008 at 12:24 AM
Thanks for posting this fix. Worked first time for me.
Posted by: Rick | Aug 30, 2009 at 05:49 PM
Thanks that did the trick
Posted by: kalyan | Oct 15, 2009 at 02:28 PM
thank you thank you thank you! I was going crazy with this!
Posted by: GoBarbGo | Feb 04, 2010 at 08:03 AM