Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • MySQL won’t start on Snow Leopard

    Posted on December 31st, 2010 phpguru 6 comments

    I recently spent a lot of time scratching my head over this. Partial solution only at this point, any additional ideas would be most welcome.

    I restored a Time Machine backup from an older 32-bit MacBook Pro onto a new 64-bit MacBook Pro. Apache & PHP worked fine, but I had compiled the 32-bit version of 5.1 on the 32-bit box. I had problems with MySQL starting after the restore, which led me to rm -rf everything related to MySQL including the /Library/StartupItems/LaunchDaemon, reboot, and install the 5.1.54 from the 64-bit dmg download installer.

    After this, I figured I’d be fine, The MySQL preference pane in System Prefs shows “stopped”. Clicking start has no effect.

    ps aux | grep mysql

    shows only my grep command.

    I had to do a few things to get MySQL partially working.

    1) I had to

    chown -R mysql:wheel mysql-install-dir/bin
    chown -R mysql:wheel mysql-install-dir/data

    2) I discovered I can only start MySQL if, from terminal, I do:

    sudo /usr/local/mysql/bin/mysqld_safe --user=root

    I can’t connect to mysql from the command line with the dreaded

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

    I do another

    ps aux | grep mysql

    and see it’s starting with


    So I make a symlink

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

    and try again

    mysql -u root -p

    Yes! Now I can use MySQL from the command line. After Googling for hours, I’ve seen others with similar install/starting problems on the latest Snow Leopard. I think it all has to do with file permissions on the /bin and /data directories.


    6 responses to “MySQL won’t start on Snow Leopard” RSS icon

    • I finally gave up on the packages from the Oracle team and loaded MAMP. Everything works beautifully; MySQL, Apache, and PHP.

    • I just started up my laptop again, and after all the stuff I did above, again I get the dreaded:

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

      MySQL wasn’t running.

      So it must not be launching at boot.

      Rats. Where’s mysqld_safe again?

      locate mysqld_safe

      ln -s /usr/local/mysql-5.1.54-osx10.6-x86_64/bin/mysqld_safe ~/mysqld_safe
      sudo mysqld_safe –user=root

      Command-T opens a new terminal.

      mysql -u root -p

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


      So I tried

      mysql –help

      which said, in part,

      socket (No default value)

      So I tried

      mysql -u root -p –socket=/var/mysql/mysql.sock

      Access denied to ‘root’@’localhost’ (using password=YES)

      mysql –socket=/var/mysql/mysql.sock -u root

      Worked. Note to self: change (add) a root password.

      I’m guessing now I can put /var/mysql/mysql.sock into /private/etc/my.cnf …

      So I do

      sudo vi /private/etc/my.cnf

      It already has a config group for mysqld (but not mysqld_safe…)

      So I add


      and save it.

      On a whim, I try

      cd ~
      mysqld_safe -u root


      Then I ps aux | grep mysql, find the process id and sudo kill 977
      Another ps aux | grep mysql shows its not running anymore.

      Now I do

      mysqld -u root

      worked (terminal has different output)
      sudo mysqld -u root
      110104 20:09:57 [Warning] Setting lower_case_table_names=2 because
      file system for /usr/local/mysql-5.1.54-osx10.6-x86_64/data/ is case
      110104 20:09:57 [Note] Plugin ‘FEDERATED’ is disabled.
      110104 20:09:57 InnoDB: Initializing buffer pool, size = 8.0M
      110104 20:09:57 InnoDB: Completed initialization of buffer pool
      110104 20:09:57 InnoDB: Started; log sequence number 0 45289556
      110104 20:09:57 [Note] Event Scheduler: Loaded 0 events
      110104 20:09:57 [Note] mysqld: ready for connections.
      Version: ’5.1.54′ socket: ‘/var/mysql/mysql.sock’ port: 3306 MySQL
      Community Server (GPL)

      mysql -u root

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

      So I again do

      sudo vi /private/etc/my.cnf

      and add


      and save it.

      mysql -u root


      Now /private/etc/my.cnf looks like this:




      Pref pane still shows it as stopped and does nothing useful.


      Hope it helps someone.

    • The saga continues. I found this forum thread helpful, as well as the Apple support discussion link:


    • Do this: http://forums.mysql.com/read.php?11,399397,399606#msg-399606 the pref pane now works for me.

    • My laptop had to go back into the shop again and I’m now on a loaner Macbook (slow!) and I can’t use sudo mysqld_safe -u root anymore. When I try I get MacbookPro:~ me$ sudo mysqld_safe -u root
      110125 19:42:03 mysqld_safe Logging to '/usr/local/mysql/data/MacbookPro.local.err'.
      110125 19:42:03 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
      110125 19:42:03 mysqld_safe mysqld from pid file /usr/local/mysql/data/MacbookPro.local.pid ended
      MacbookPro:~ me$
      however this works: sudo mysqld -u root

    • Brian Wrightson

      This helped a bunch – thanks!!

    Leave a reply