What a dry title.
There are a few write-ups about this here and there, but I thought I would put together the steps I went through to install MySQL on Leopard. I found that none of the posts I’ve seen do a good job of tying together all the problems that I came across. So let’s set aside the fact that MySQL should have just been there in the first place and concentrate on fixing it…
Download the Mac OS X 10.4 Package from the MySQL Developer site here.
Be sure to pick the right architecture for your Mac.
Mount the disk image and run the installer package called “mysql-5.0.XX-osx10.4-ARCH.pkg” or similar. Substitute minor version numbers and “ARCH” where appropriate.
I won’t go through the steps inside the installer, that would be tedious.
At the end of it all you will have a lovely working install of MySQL 5.0 in
/usr/local/mysql-5.0.XX-osx10.4-ARCH and a handy symlink to that directory at
Now for the problems.
Problem 1 – The startup item doesn’t work
launchd has killed the old StartupItems folder and functionality, someone should have told MySQL that was coming.
Here is a launchd plist file that you can use in it’s place:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>GroupName</key> <string>mysql</string> <key>KeepAlive</key> <true/> <key>Label</key> <string>com.mysql.mysqld</string> <key>Program</key> <string>/usr/local/mysql/bin/mysqld_safe</string> <key>UserName</key> <string>mysql</string> </dict> </plist>
Save the above code into a file at
Change it’s ownership to root:
$ sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysqld.plist
Load the launchd job thusly:
$ sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld.plist
Stop MySQL and unload the job like this:
$ sudo launchctl stop com.mysql.mysqld $ sudo launchctl unload /Library/LaunchDaemons/com.mysql.mysqld.plist
Unloading takes a couple of uncomfortable seconds to complete, just be patient.
Problem 2 – The preference pane doesn’t work
Well, that’s just tough. Presumably the preference pane relied quite heavily on the startup item. So with that dependancy broken it’s back to the command line.
Problem 3 – “mysql” not found on command line
I had success fixing this by adding the following line to a new file at
Then exit the current terminal window and open a new one.
This may not be the bestest most official way to do it, but it works.
Problem 4 – Built in PHP doesn’t like the MySQL socket
True, the default socket for MySQL and MySQLi extensions on PHP is set to
/var/mysql/mysql.sock but the MySQL we just installed creates the sock file in
This is not a problem for everyone, most PHP apps don’t use the default mysql settings.
To change this just create a file at
/etc/php.ini and put this in there:
[MySQL] mysql.default_socket = /tmp/mysql.sock [MySQLi] mysqli.default_socket = /tmp/mysql.sock
There is no need to copy the whole php.ini.default file over to this location, of course if you already have a php.ini file, then just change or append these settings into that file.
Restart the built in Apache.