-
MySQL won’t start on Snow Leopard
Posted on December 31st, 2010 6 commentsI 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
/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=root --log-error=/usr/local/mysql/data/MacbookPro.local.err --pid-file=/usr/local/mysql/data/MacbookPro.local.pid --socket=/var/mysql/mysql.sock
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”

-
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=rootCommand-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)WTH?!
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
[mysqld_safe]
socket=/var/mysql/mysql.sockand save it.
On a whim, I try
cd ~
mysqld_safe -u rootworked.
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
insensitive
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
[mysql]
socket=/var/mysql/mysql.sockand save it.
mysql -u root
worked.
Now /private/etc/my.cnf looks like this:
[mysqld]
socket=/var/mysql/mysql.sock[mysqld_safe]
socket=/var/mysql/mysql.sock[mysql]
socket=/var/mysql/mysql.sockPref pane still shows it as stopped and does nothing useful.
Whatever.
Hope it helps someone.
-
The saga continues. I found this forum thread helpful, as well as the Apple support discussion link:
http://www.phpfreaks.com/forums/mysql-help/mysql-will-not-start-snow-leopard-10-6-5/
-
Do this: http://forums.mysql.com/read.php?11,399397,399606#msg-399606 the pref pane now works for me.
-
Brian Wrightson April 3rd, 2012 at 07:59
This helped a bunch – thanks!!
Leave a reply
-



Robert Rowe January 5th, 2011 at 08:12