Small PHP/MySQL problem...

Posted:
in Mac Software edited January 2014
Hi guys,



This might not be the place to ask but I KNOW someone here can help me.



When I try to connect to my freshly installed MySQL server through php, I get



Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Users/laurens/Sites/PhpProject1/index.php on line 10



And I think this is because MySQL Administrator GUI tool says the socket is at /tmp/mysql.sock



Now... what do I change and where do I change it? I'm a noob at this stuff...



Many thanks in advance!

Comments

  • Reply 1 of 2
    MarvinMarvin Posts: 15,322moderator
    That's right, the sock file is in a different place from where it expects. I usually make a link so it works either way. Basically, open a terminal (/Applications/Utilities/terminal) and type in:



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



    You could also change the path in the SQL server GUI but sometimes this breaks other software, which expects the sock file to be in /tmp. The link covers both cases.
  • Reply 2 of 2
    Submit a bug report to MySQL.



    Your package should have lock files in the /var/ pathway, by default. You should not have to ln -s to /var/. The package maintainer should manage this in their postinstall scripts.
Sign In or Register to comment.