Sidebar: Python, MySQL, Snow Leopard Installation

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:

  1. Find out what architecture your Mac is, if you don’t know already. Here’s a reference.
  2. Install Xcode, if necessary, version 3.2.6. 
  3. 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).
  4. Download MySQLdb 1.2.3 .
  5. 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 .
  6. Bring up a python monitor and try to import MySQLdb. If that works you’re done.
  7. 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…



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