I posted this on the Zend forum, but I'm hoping I can get a speedier reply here. I've tried every solution provided on this forum with no luck. When I restart mysql, everything appears ok.

sudo /usr/local/zend/bin/zendctl.sh restart 
/usr/local/zend/bin/apachectl stop [OK]
/usr/local/zend/bin/apachectl start [OK]
Stopping Zend Server GUI [Lighttpd] [OK]
spawn-fcgi: child spawned successfully: PID: 7943
Starting Zend Server GUI [Lighttpd] [OK]
Stopping Java bridge [OK]
Starting Java bridge [OK]
Shutting down MySQL
Starting MySQL

Pinging locahost is also OK and resolve dns to IP.

ping localhost
PING localhost ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.048 ms
64 bytes from icmp_seq=1 ttl=64 time=0.064 ms
64 bytes from icmp_seq=2 ttl=64 time=0.066 ms
64 bytes from icmp_seq=3 ttl=64 time=0.076 ms
64 bytes from icmp_seq=4 ttl=64 time=0.064 ms

But when I attempt to access the local url for my app, I get the dreaded:

Message: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

This is a show-stopper for me. I appreciate any assistance. Thank you.

  • so, here's an update... my 'puter has lost it's mind. all kinds of whacko stuff has been happening. my guess is that this issue is more a symptom of a larger problem. so, yesterday, i wiped and rebuilt it. today, i get to start over and hopefully return to happy developer's land. both answers appear quite helpful. i appreciate the responses. i'll mark them as such, but i don't know if either solves my issues because i think this issue is a "red herring". thanks for the help. how do i give each credit for your efforts? – Mike S. Dec 20 '09 at 14:05

You can set the socket location in your application config file. If you set it for your local dev environment by adding the following line:

resources.db.params.unix_socket = /usr/local/zend/mysql/tmp/mysql.sock

No more need to link the socket by hand.


MySQL's idea of localhost isn't the IETF's idea of localhost. To MySQL, localhost means "a Unix socket of random location", which is the cause of endless frustration (and, in all likelihood, anal warts and global warming). If you want to use a Unix socket, then you'll need to configure Zend to use the correct socket (I don't know how, nobody seems to be able to decide on a standard location for the socket, nor a standard way to tell everything else where it is). Honestly just changing your server address to, which means "localhost, no really, I'm not kidding, yeah, the real one on the network" is a far less frustrating way to go (just make sure you've told MySQL itself to listen on the network by removing skip-networking).


Check your /etc/mysql/my.cnf and see what socket is set to under your [mysqld] section. Then, you can either change that to /tmp/mysql.sock or just make a symlink to where it puts it, e.g.

ln -s /var/run/mysqld/mysql.sock /tmp/mysql.sock

Of course most *nix OS's wipe /tmp on shutdown so the first method is probably best, unless you're me and think that the socket has no business being in /tmp

And on a side note, you should check out the Python framework Django, it made me happily leave Zend Framework in the dust.

  • thx for the comment. but when the boss says "zend framework", then that's what we do -- nowatimsayin'. ;-) – Mike S. Dec 20 '09 at 13:59
  • Indeed I do. :) – SleighBoy Dec 21 '09 at 6:54

The default Mac Zend install creates the socket file here:


Take a look at the "socket" variable in your "my.cnf" file located in "/usr/local/zend/mysql/data" to identify where it is or move it to a more convenient spot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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