Wednesday, January 19, 2011

mysql.sock problem on Mac OS X, all Zend products

Hi folks. 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 
Password:
/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
. SUCCESS! 
Starting MySQL
. SUCCESS!

Pinging locahost is also OK and resolve dns to IP.

ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.064 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.066 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.076 ms
64 bytes from 127.0.0.1: 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.

  • 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 127.0.0.1, 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).

    From womble
  • 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.

    Michael Stelly : thx for the comment. but when the boss says "zend framework", then that's what we do -- nowatimsayin'. ;-)
    SleighBoy : Indeed I do. :)
    From SleighBoy
  • The default Mac Zend install creates the socket file here:

    /usr/local/zend/mysql/tmp/mysql.sock

    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.

    From

0 comments:

Post a Comment