Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After running Mac OS X updates this morning when I run PHP projects on my local machine, when they were fine last night are now giving me errors:

mysql_connect() [function.mysql-connect]: [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 540]

Has anyone had a similar problem?

Jonesy

share|improve this question
add comment

3 Answers 3

From apple support forum : http://discussions.apple.com/thread.jspa?messageID=12176949


I had the same problem and fixed it by editing my php.ini file:

  1. In Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)

  2. Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock

  3. Press Ctrl-O, then Enter to save

  4. Still in Terminal, type sudo apachectl graceful

  5. That's it!


share|improve this answer
    
thanks for the link. It hasn't fixed it though, is it anything to do with me having a php.default.ini instead? –  iamjonesy Sep 6 '10 at 17:39
    
I don't think PHP will read php.default.ini. This FAQ explains where to find php.ini - you might just rename php.default.ini to php.ini. –  pjmorse Oct 19 '10 at 17:18
    
Also consider changing mysqli.default_socket = /tmp/mysql.sock for MySQLi and pdo_mysql.default_socket=/tmp/mysql.sock for PDO –  Burak Erdem May 19 '11 at 17:11
add comment

It appears that MySQL is no longer running. How did you install MySQL? Does it report any error when you try to start/restart it?

share|improve this answer
    
it's running but when I try to restart it i get an error: Stopping server... ERROR! MySQL manager or server PID file could not be found! Failed to stop server, trying shutdown... Stopped server. –  iamjonesy Sep 5 '10 at 11:57
    
I'm using MySQL Administrator for MacOSX btw –  iamjonesy Sep 5 '10 at 14:39
    
Has your /etc/my.cnf file changed? Maybe you're connecting via TCP or something now? When in the mysql client, type \s to see where the socket is now (or if you're using TCP, etc) –  barrycarter Oct 20 '10 at 19:00
add comment

you can start the mysqld deamon pointing to any socket file that you want. You just have to say to the client as well which file you want to use.

In your case i would:

  • check if the /var/mysql directory exists
  • check if your user has permission to write file on this directory

you can try to start your deamon using a socket file like:

mysqld_safe --socket=/tmp/mysql.sock

and then with your mysqlclient you can do something like

mysql -u user -p --socket=/tmp/mysql.sock

it will work

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.