Blog.Andrei.MD

Andrei Railean's Image

I am Andrei Railean

Andrei.MD is all about me

Article Archive RSS

Nov
5th
Fri
permalink

PHP MySQL localhost not finding socket on mac

On my mac, PHP wouldn’t connect to MySQL to “localhost” server. It turns out that when “localhost” is used, MySQL uses sockets instead of TCP/IP connection. Terminal mysql access to localhost was fine, which suggested that there’s nothing wrong with MySQL config. Only after a while did I think to look at php.ini to see if there are any setting there. Yep, my mac uses /tmp/mysql.sock and php.ini was setup to use /dev/mysql/mysql.sock. After changing to /tmp/mysql.sock and restarting apache it now works like it should. 

Hope you find it helpful.

Comments (View)
Tags: MySQL technical developer