Installing MySQL 5.0 on Mac OS X 10.5 client

Leopard Tank - Boom!

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…

Obtain MySQL

Download the Mac OS X 10.4 Package from the MySQL Developer site here.

Be sure to pick the right architecture for your Mac.

Install MySQL

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 /usr/local/mysql

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"
<plist version="1.0">

Save the above code into a file at /Library/LaunchDaemons/com.mysql.mysqld.plist

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 ~/.profile


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 /tmp/mysql.sock

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.default_socket = /tmp/mysql.sock

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.

In summary


  1. Stephanie said:

    Thanks for this tutorial! It definitely addresses problems otherwise missed by others.

    I’m just having trouble following your fix to Problem 3. What did you name that new file you created?

  2. @Stephanie

    The file is named “.profile” (note the period at the start of the file). It needs to be saved to the root of your home directory (~/.profile).

  3. Brian Christensen said:

    Thanks a lot for sharing the info.

  4. When I try the “sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld.plist”, I get errors. I’ve checked over the plist file and it looks fine in pico. I DID set the owner and group properly as well.


    -> sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld.plist
    launchctl: propertyList is NULL
    launchctl: no plist was returned for: /Library/LaunchDaemons/com.mysql.mysqld.plist
    launchctl: no plist was returned for: /Library/LaunchDaemons/com.mysql.mysqld.plist
    nothing found to load

    Any suggestions? I’m on 10.5.1 with an install that was fresh just a few hours ago.

  5. You might also try creating a symlink to the mysql.sock rather than changing a config:

    $ sudo mkdir /var/mysql
    $ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

  6. @ Brandon Harper

    You could do that, but I tend to shy away from using symlinks in that fashion. It’s just too easy to forget that they are there sometimes and they can cause unexpected consequences. A nice config file put where it is supposed to be is far easier to track and re-configure than a symlink IMHO.

  7. Hey, great instructions. Just curious, does this yeild the same or similar result as just installing MAMP ( I’ve just started using it as a way to test pages and blogs localy before they go live and I’m loving it.

  8. Thanks for the write up. For the lazy who can’t stand mucking with the command line, there’s also a tool called MAMP that simplifies the process of configuring MySQL, PHP, and Apache on the Mac enormously.

    Yes, I’m lazy.

  9. Ryan said:

    those who are getting ‘propertyList is NULL’ errors:

    You can run this at the command-line to troubleshoot XML errors:
    perl -MXML::Parser -e ‘$p = new XML::Parser(Style=>”Debug”); $p->parsefile(“your_file.plist”);’

    This should spit out any errors the parser detects

  10. jsaudiotn said:

    This was great. Thanks.

  11. Thanks! Very helpful. I have 10.5.7 and used the path ~/Library/LaunchAgents/ instead of /Library/LaunchDaemons, since that’s where my other .plist files were located.

    Haven’t yet figured out how to actually start this new installation of MySQL, but I’m sure I’ll get there.

  12. Pingback: Andrew Colclough

  13. Sam,

    This just saved me quite a bit of trouble after switching to a new Mac and a new version of MySQL. Thanks for the perfect write-up.


    P.S. Code is poetry 😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: