Installing MySQL on Leopard

MySQL now provides compiled binaries for Mac OSX 10.5 Leopard. But the startup applet doesn’t work properly yet on Leopard.

So here’s how to install MySQL on Leopard and start it using launchd – the standard Leopard way. These instructions should work for both Tiger (10.4) and Leopard (10.5).

  • Download MySQL for your OS and architecture (PowerPC or Intel; 10.4 Tiger or 10.5 Leopard)
  • Install MySQL from the package in the dmg – something like mysql-5.0.51a-osx10.5-x86_64.pkg
  • DO NOT install the startup item package – it doesn’t work on Leopard (as of version 5.0.51a).
  • DO NOT install the preference pane – it doesn’t work on Leopard (as of version 5.0.51a, though a fix is in the works).

Starting MySQL

Since neither the preference pane nor startup item work on Leopard, let’s use launchd to start MySQL instead.

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
  • Stop mysqld with an unload
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist

The -w in either of these commands leaves mysqld running (and restarts it as needed) until you turn it off with the other launchctl command.

For convenience, you may want to create an alias for these commands in .bashrc

alias start_mysql='sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist'
alias stop_mysql='sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist'

One other convenience – put mysql and mysqldump into your path:

cd /usr/local
sudo ln -s mysql-5.0.51a-osx10.5-x86_64 mysql
cd bin
sudo ln -s ../mysql/bin/mysql .
sudo ln -s ../mysql/bin/mysqldump .

Done. So we’re ready to fire it up and connect:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
mysql -u root -p