Fork me on GitHub

Missing mysql.sock file in ZendServer (Mac OSX)

I have spent the best part of today tearing my hair out, trying to figure out why the mysql.sock socket file was missing from my clean ZendServer CE install. From googling a little on the subject it seems I am not the only one to suffer this fate. Turns out that none of the solutions suggested in these articles applied for me.

A few weeks back, when I got my brand new MacBook Pro I decided to play around with ZendServer, and ended up changing things so much that I decided to just do a clean install. So I followed Zend’s method of uninstalling the server and proceeded to install my new, fresh copy. I was a little surprised when I was receiving errors from my mysql instance…

ERROR 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

I did a little digging around my Mac, I tried running a find..

sudo find / -name mysql.sock

But this returned nothing. The mysql.sock file is apparently located at /usr/local/zend/mysql/tmp/mysql.sock or alternatively /tmp/mysql.sock, but mine had vanished from the file system completely. After a little digging, I found a shell script bundled in with ZendServer, /usr/local/zend/bin/uninstall.sh. Running this script cleaned out my current installation and after performing another clean install of ZendServer I had my mysql.sock file back where it should have been.

It’s pretty strange as to why Zend haven’t updated their instructions for removing ZendServer correctly, and it can potentially cause a lot of issues if you’re hoping to use mysql in the future.

12 Comments

  • I thought this was strange when I first saw your post, then eventually suffered the same fate. Given the issues I (and many others) have had with OS X Lion and Zend Server CE I’m giving MAMP another trial run…

    • Yeah, it’s definitely a strange one. I think its because OSX Lion has dropped built-in MySQL support and Zend Server CE doesn’t come with its own socket file for MySQL on the Mac (AFAIK). Hopefully they should resolve it in a future update.

      Currently I’m running XAMPP on my MacBook and MAMP on my iMac and neither are giving me any issues, I would probably recommend XAMPP over MAMP though if you haven’t tried it.

  • If you guys are using Mysql workbench try to shut down your server and see if it says something along the lines of:
    2011-10-21 14:37:10 – Stopping server…
    2011-10-21 14:37:14 – Stop server: Warning: World-writable config file ‘/usr/local/zend/mysql/data/my.cnf’ is ignored
    Warning: World-writable config file ‘/usr/local/zend/mysql/data/my.cnf’ is ignored

    This means that the configuration file where you store your settings is being ignored -> hence you cant expect to be making changes in that file and see those changes kick in once you start the server. So try this:
    1. make changes to that file.
    2. find it through finder and change back the permissions so that everyone can read but not write to it.

    … then some magic takes place and the mysql server says to itself -> hmmm… that file is restricted – I can read it but I also know that only the administrator can write to it… which means its a good file for me to use when I set my settings using what’s written in there. :)

    Also it is no coincidence that the mysql.sock file is placed in a folder called “tmp” which is short for temporary aka it was bound to dis-sapper from time to time.

    I had the same problem: missing sock file and the above procedure worked for me without re-install on OSX Lion :)

    Enjoy :)

  • My sock file kept on disappearing each time I restarted , even after making a clean install, so I kept on searching , this is what I found :

    http://www.thedeveloperblog.net/guide-setup-zend-server-mac/

    It finally solved the problem once and for all.
    Mac OSX Lion 10.7.3

    Thanks to Tobias Raatiniemi.

    CONFIGURE YOUR ZEND SERVER CE INSTALLATION
    There are a few things that we need to do in order for ZendServer to work the way we want. So, the first thing we’re going to do is to enable MySQL by default. For some reason the ZendServer script for starting, restarting and shutting down do not include MySQL. So, if you’ve had problems connecting to your MySQL database after a reboot or been getting the error that mysql.sock is missing, this might be why.

    Fire up the terminal, either by using spotlight or going to your applications folder and issue the following command to begin editing the ZendServer script, it will open the script in the text editor nano.

    sudo nano /usr/local/zend/bin/zendctl.sh
    On the fifth line you’ll see the following statement:

    MYSQL_EN=”false”;
    Change it to the following:

    MYSQL_EN=”true”;
    Now, go further down within the file, until you come to the start sequence. Here we’re going to add one line that’ll issue the “start-mysql”-command. This is what your start sequence should look like.

    “start”)
    $ECHO_CMD “Starting $PRODUCT_NAME $PRODUCT_VERSION ..\n”
    $0 start-zdd %
    $0 start-monitor-node
    $0 start-mysql %
    $0 start-apache %
    $0 start-lighttpd %
    $0 start-jb %
    $0 start-jqd %
    $ECHO_CMD “\n$PRODUCT_NAME started…”
    ;;
    Below the start sequence you’ll find the restart sequence, which should look like this.

    “restart”)
    $0 restart-zdd
    $0 restart-monitor-node
    $0 restart-apache
    $0 restart-mysql
    $0 restart-lighttpd
    $0 restart-jb
    $0 restart-jqd
    ;;
    And, if you go further down you’ll find the stop sequence, which should look like this.

    “stop”)
    $ECHO_CMD “Stopping $PRODUCT_NAME $PRODUCT_VERSION ..\n”
    $0 stop-apache %
    sleep 2
    $ZCE_PREFIX/bin/clean_semaphores.sh
    $0 stop-lighttpd %
    $0 stop-jb %
    $0 stop-mysql
    $0 stop-jqd %
    $0 stop-zdd %
    $0 stop-monitor-node %
    $ECHO_CMD “\n$PRODUCT_NAME stopped.”
    ;;
    Now, save and exit by pressing ctrl+x, select “Yes” to the question “Save modified buffer” and write to the same filename.

    The next thing we need to do is to make sure that the correct script is executing when starting up OS X. To do this you’ll need to go to the startup directory, remove the old script and link in the new script:

    cd /Library/StartupItems/ZendServer_init/
    sudo rm zendctl.sh
    ln -s /usr/local/zend/bin/zendctl.sh ./
    To ease maintenance we’re going to setup a link within the our sbin-folder.

    cd /usr/sbin
    ln -s /usr/local/zend/bin/zendctl ./

    • This is an awesome solution. Thanks!

      • Great solution! thanks a lot dude! saved in my delicious!

  • thanks.
    wonderful job done

  • @Jing Li : Thank you very much!

  • Thanks! Big thanks!

  • Followed all the above and no longer get any warnings about the .cnf file but I still don’t have a .sock file anywhere…. any ideas?

  • When someone writes an article he/she maintains the
    plan of a user in his/her mind that how a user can be aware of it.

    So that’s why this article is great. Thanks!

    Also visit my web page: Sidney Crosby Authentic Jersey

  • I really like reading through a post that can make men and women think.
    Also, thank you for permitting me to comment!

    Feel free to visit my page … More hints

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>