Install python MySQL (MySQLdb) in Mac OS X Snow Leopard 10.6

I hate MySQL but I have some … employees … who think it’s a perfectly fine solution when you don’t want to boot a Solr server. Savages. Anyway, of course I expected the MySQLdb connector in Python to totally break and it did not disappoint. You’re dealing with a 64-bit version of Python now and a computer that gets confused as to its architecture (why does /usr/bin/arch return i386 when gcc outputs x86_64 by default?)

Here’s what you do:

  • Download the Mac OS X 10.5 x86_64 version of MySQL. You need the 64-bit one. Get the package format installer, it’s easy. Run the installer.
  • Add /usr/local/mysql/bin to your PATH and add the ARCHFLAGS variable to your environment. I always edit /etc/bashrc, you can also use ~/.bash_profile if you want. But you need both environment variables. Something like:
    export PATH=$PATH:/usr/local/mysql/bin
    export ARCHFLAGS="-arch x86_64"
    
  • Download the latest source version of MySQL-python. It should end in .tar.gz. Right now it’s 1.2.3c1. Unpack it and run sudo python setup.py install. You don’t need to do anything with commenting out uints anymore like you did in Leopard.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s