Skip to content

Instantly share code, notes, and snippets.

@santosh79
Created August 27, 2010 01:39
Show Gist options
  • Save santosh79/552605 to your computer and use it in GitHub Desktop.
Save santosh79/552605 to your computer and use it in GitHub Desktop.
installing mysql python on snow leopard
This is assuming that you are using the stock version of python that comes with snow leopard. As of 8/26/2010 this is 2.6.1 64-bit version.
1. Download & Install "Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive" from http://dev.mysql.com/downloads/mysql/
2. Ensure there are no mysql connector fragments in /Library/Python/2.6/site-packages.
a) sudo rm /Library/Python/2.6/site-packages/_my*
b) sudo rm -rf MySQLdb lpMySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg
Basically, ensure there are no files that could be possibly be mysql related in /Library/Python/2.6/site-packages. Err on the side of removal.
3. Download Mysql-Python version 1.2.3 from http://sourceforge.net/projects/mysql-python/
4. Untar & cd into MySQL-python directory.
5. sudo rm -rf build (It shouldn't have a build directory but if it does delete it).
6. Edit setup_proxy.py & replace:
the line starting with “mysql_config.path =”
with
mysql_config.path = “/usr/local/mysql/bin/mysql_config”
7. Create a symbolic link -- sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
8. CLEAN: python setup.py clean
9. BUILD: ARCHFLAGS="-arch x86_64" python setup.py build
10. INSTALL: sudo ARCHFLAGS="-arch x86_64" python setup.py install
11. TEST if it works: open a python interactive session & type "import MySQLdb". It shouldn't throw any errors.
Some useful resources:
1. HOW-TO Uninstall mysql: http://gist.github.com/552603
2. http://learninglamp.wordpress.com/2010/02/21/mysqldb-python-mysql-and-os-x-a-match-made-in-satans-bum/
3. http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment