Macos – Mysql 5.6 server via MacPorts won’t start

macosmacportsMySQL

I've been happily using MacPorts' mysql5 and mysql5-server. Now it's time to upgrade. I followed standard procedure, but the server won't start.

sudo port unload mysql5
sudo port install mysql56 mysql56-server mysql_select
sudo port select -set mysql mysql56
sudo port load mysql56-server

No errors. When I run ps aux | grep sql I see it's not running. I tried setting the socket in my.conf and running mysql5_install_db (but that seems specific to the older package). File permissions look correct. There's no mysql error log yet. How do I get this server started?

Best Answer

Figured it out. Opened LaunchDaemon plist file to see the exact command which would run. Ran that manually to see the startup output and eventually came up with the solution:

sudo mysql_install_db5 --datadir=/opt/local/var/db/mysql56
sudo chown -R _mysql:_mysql /opt/local/var/db/mysql56/
sudo mysql_upgrade

If you need help tracking down startup errors, open Console and messages containing "mysql". In my case the process was quickly closing, causing an infinite loop of retries. To dig deeper, open this file to see how it's launched:

/Library/LaunchDaemons/org.macports.mysql56-server.plist

From there we can see it basically runs

/opt/local/bin/daemondo --label=mysql56-server --start-cmd /opt/local/lib/mysql56/bin/mysqld --user=_mysql

So at the command line try

sudo -u _mysql /opt/local/lib/mysql56/bin/mysqld

and watch the startup output.

Related Question