Installing MySQL on Snow Leopard
Early on at Cisco, I realized that it’s really beneficial to write down (step by step) what I’ve done when I install something new. It forces me to think about what I’m doing, it provides me with a guide in case I mess up and have to start over, and other people can benefit from it later.
With that in mind, I’ve decided to document my installation of MySQL on Snow Leopard (OS X 10.6). Hopefully, someone will get some use out of it, but if not, at least I’ll have documentation of what I did.
The PATH Variable
MySQL has a bunch of useful executables that aren’t in PATH by default. I could symlink to them, but I think that’s less maintainable than just appending to PATH.
- Open the Terminal
- Open up the .bash_profile file in your home directory. This is a bash script that runs every time you start the Terminal, so the PATH variable will be extended properly every time. If you have TextMate and its UNIX command line tools installed, do it like this:
mate ~/.bash_profile
Otherwise, do it like this:
/Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.bash_profile &
If you use the second one, make sure to add the ampersand at the end.
- We want to add MySQL’s bin folder to PATH. MySQL’s going to be installed at /usr/local/mysql, so let’s add /usr/local/mysql/bin to PATH. Add the following line to .bash_profile:
export PATH="/usr/local/mysql/bin:/usr/local/sbin:$PATH"
This replaces PATH with two new locations and the old value of path (so essentially, appending the two new locations to the beginning of PATH). You’ll notice that, in addition to /usr/local/mysql/bin (which I mentioned earlier), I also added /usr/local/sbin. OS X doesn’t include this in PATH by default, but I think it should, so I added it. I have no defense for that position, but this is as much a guide for myself as it is a guide for other people, so I don’t need to defend it :)
- Save the updated .bash_profile and close it.
- Quit and reopen Terminal so that .bash_profile will be rerun (you could also run it explicitly, but I prefer quitting and reopening).
- Run the following command:
echo $PATH
You should see /usr/local/mysql/bin and /usr/local/sbin in there now.
- Edit: Restart your computer. My installation worked without doing this, but Jon (in the comments) said he needed to do this before it worked, so you might as well.
Downloading + Installing
I might try compiling and installing from source at some point, but I don’t see any reason to when there are official OS X binaries available. Worst case scenario, it messes with a bunch of my settings, and I’ll uninstall and then do it from source.
- Go to http://dev.mysql.com/downloads/mysql/5.1.html#downloads
- Scroll down to the Mac OS X section (near the bottom). Download the version labeled “Mac OS X 10.5 (x86_64)”. It’s very important that you download the 64-bit version. The 32-bit one will give you preference pane problems (I call them PPPs whenever I talk about them, though this is the first time I ever have). Eventually, there’ll probably be a Mac OS X 10.6 version, but for now, this works perfectly.
- Open the .dmg, then run mysql-x.x.xx-osx10.5-x86_64.pkg. Continue through all the screens without changing anything, until it finishes.
- Optional: install the preference pane by running MySQL.prefPane.
- Optional: make MySQL start up along with OS X by running MySQLStartupItem.pkg. I didn’t do this (I often use my computer for things other than development, and I don’t want to bog it down unnecessarily), so I can’t provide any instruction or vouch for how well it works on Snow Leopard.
You should now be able to start MySQL by going into the MySQL preference pane and clicking “Start MySQL Server”. If it doesn’t work, leave me a comment, and I’ll try to help you.

Thanks! This really helped!
I also found this very helpful, quick and simple.
For some reason, I’m still having PPP. I installed the 64 bit version because the prefs panel item was “grayed” out and not accessible. I still have the same problem with the 64 bit one. If you have any idea what causes this let me know. If not, I’ll keep digging and trying.
Pete: I shouldn’t make up acronyms on the fly anymore. I had to re-read my post to understand what you meant :)
Anyways, just as a sanity check, are you on Snow Leopard or just regular Leopard? A few people have emailed me with problems, only to realize that they were on regular Leopard (32-bit).
Jake, Did you have a previous 32bit version of mySQL installed before you added the 64 bit version?
douglasbrown: I don’t think so. I followed these steps almost immediately after installing Snow Leopard.
If Snow Leopard comes with its own 32-bit version of MySQL installed, then yes, but that would seem a little silly to me.
Thanks for the writeup. it worked perfectly.
VN: No problem, glad I could help.
Worked perfect. Thanks so much for posting this as it made my life easier. I am coming over from M$ Windows to Mac OS X (and loving it) after 20 years of software development (DOS, Windows, Linux).
No problem Burton. I made the move myself a couple years ago. Glad this made things easier for you!
Hi, I followed your instructions and it didnt give me any error… but dont know where is the mysql folder is. I installed it on default path..
cheers,
hamid:
When you say “the mysql folder”, are you talking about the location it was installed in? Or are you asking where to go to start/stop it from running?
The folder where MySQL is installed (by default) is /usr/local/mysql. From within there, the executables are in bin.
To actually run MySQL after doing this installation (assuming you followed the preference pane installation instructions), go to the Apple menu, click “System Preferences…”, and click the MySQL button on the bottom row. From there, you can start/stop the server, and choose whether or not the server should start when your computer starts.
Is this what you’re asking? Or is it something else?
as i upgrade from 10.5 to 10.6 , i found that i use .profile instead of .bash_profile. i think the first one is the default IMO.
thanks for your simple how to.
I did all of this, but when I went to run it I got the following:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
any idea?
Awesome. This fixed my problem perfectly. Thanks!
If you are still having trouble running the installer (hanging at preparing) be sure to reboot after taking all the steps under “The PATH Variable”. It still wouldn’t install for me but after a reboot it worked. Thanks for the info.
Jon: Thanks for the info! I’ll add it to the set of instructions.
So I have the latest mySQL (64-bit) installed on Snow Leopard. Now how do i begin creating a database? I downloaded myPHP but can’t seem to find where to start. I am a designer by trade and want to move into getting my sites more dynamic. Can I do all this with a GUI rather than going through terminal and typing code?
bluemantis: Yep, but it’ll cost you.
I’ve experimented a bit with a program called Querious: http://www.araelium.com/querious/
I really really like it. As a developer, I’m perfectly comfortable on the command line and with phpMyAdmin, but for a designer, Querious might be much preferable.
Either way though, I would definitely recommend picking up a book on MySQL. Using it is going to be a constant struggle if you don’t have a basic understanding of the code involved, so while it may be an annoying initial investment, you will save yourself huge headaches (and a lot of time) in the long run.
I bought a book on it (a bit cryptic, if you asked me)–The Definitive Guide to MySQL 5 by Michael Kofler, from apress. Is it any good? Lastly, Would it make any sense for a non-developer (such a I) to delve into this? Or is that overextending oneself?
bluemantis: Honestly, I’m not sure what you’ll be able to do with a database without a bit of programming knowledge as well. With a basic amount of each, you could do some cool stuff, but with just MySQL, I’m not sure if you’d be able to do anything.