Wednesday, October 3, 2012

mysql_connect() [function.mysql-connect]: [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

I had my website running on CentOS.. but when I moved it to MAC OS X I started getting this weird error. After having spent a lot of time on troubleshooting.. I found a very simple solution to it... 

The problem is that mysql get's the location of socket file to use incorrect. In my case it was trying for socket file at /var/mysql however on my MAC the socket file are created at /tmp. 

All that I did to correct this problem was: 

1.  Goto /var
2.  Create a directory named mysql
3.  Create symbolic link named mysql.sock to /tmp/mysql.sock
     sudo ln -s /tmp/mysql.sock mysql.sock


No comments:

Post a Comment