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:
[code lang="bash"]mate ~/.bash_profile[/code]
Otherwise, do it like this:
[code lang="bash"]/Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.bash_profile &[/code]
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:
[code lang="bash"]export PATH="/usr/local/mysql/bin:/usr/local/sbin:$PATH"[/code]
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:
[code lang="bash"]echo $PATH[/code]
You should see /usr/local/mysql/bin and /usr/local/sbin in there now.
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!
ReplyDeleteI also found this very helpful, quick and simple.
ReplyDeleteFor 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.
ReplyDeletePete: I shouldn't make up acronyms on the fly anymore. I had to re-read my post to understand what you meant :)
ReplyDeleteAnyways, 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?
ReplyDeletedouglasbrown: I don't think so. I followed these steps almost immediately after installing Snow Leopard.
ReplyDeleteIf Snow Leopard comes with its own 32-bit version of MySQL installed, then yes, but that would seem a little silly to me.