I just had to install MySQL on my Snow Leopard (OS X 10.6) Mac interfacing to it with Python using MySQLdb. This installation is not necessarily straightforward, and its difficulty depends on how mindful or lucky you are of keeping track of whether you’re on a 32 or 64 bit architecture. So here’s my recipe for getting it to work:
- Find out what architecture your Mac is, if you don’t know already. Here’s a reference.
- Install Xcode, if necessary, version 3.2.6.
- Download the correct mysql (32 or 64 bit version) for your architecture OR check your existing mysql for correctness using the command: file /usr/local/mysql/bin/mysql (or your path to mysql).
- Download MySQLdb 1.2.3 .
- Untar it and edit site.cfg, setting the mysql_config variable to the canonical path to the mysql_config file associated with your version of mysql. Use the canonical path to mysql_config, it may not work with a directory that is a symbolic link. Here is mine: mysql_config = /usr/local/mysql-5.5.27-osx10.6-x86_64/bin/mysql_config .
- Bring up a python monitor and try to import MySQLdb. If that works you’re done.
- If not, read your error message If there is a message about a missing libmysqlclient.18.dylib you will want to put a symbolic link in place (sub your paths if necessary): sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
That’s it! Now back to our regular scheduled programming…