« Documentation for Prototype.js the Javascript Library | Main | Apple's New 13" MacBook Big and Heavy »

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: , , ,

Comments

beck

You are my new best friend. Thank you so much! (I'm gonna go click on some of your ads now.)

Richard Vincent

This solution worked for me as well!

Thank you very much.

-Rich

tahir

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

Bindu

thank you, thank you and thank you!!
wordpress is finally working for me, yippee! suddenly the sun is shining brighter:)

cheers,
Bindu

renee

thank you so much!

Ben

Lifesaver! Thanks very much for sharing this info!

Pradeep

cool...this really works for me....thank u soo much

SDK

FYI: This issue also occurs with Leopard. I applied the same solution as you suggested for Tiger and it worked great! Thank you.

Rick

Thanks for posting this fix. Worked first time for me.

kalyan

Thanks that did the trick

GoBarbGo

thank you thank you thank you! I was going crazy with this!

Post a comment

Comments are moderated, and will not appear on this weblog until the author has approved them.

If you have a TypeKey or TypePad account, please Sign In.