- Download MySQL from dev.mysql.com/downloadsÂ and install itÂ as instructed in the documentation.
- Download and extract the MySQL for Pythom from sourceforge.net. I'm usingÂ MySQL-python-1.2.2.tar.gz
- Open Terminal and go to the directory whereÂ MySQL-python-1.2.2.tar.gzÂ was unpacked to.
- It's better to delete build/ directory, just in case your installation might be interfered withÂ any previous builds
- edit file site.cfg, and edit the value of mysql_config to the correct PATH where your mysql_config reside. Mine is:
# The path to mysql_config. # Only use this if mysql_config is not on your PATH, or you have some weird # setup that requires it. mysql_config = /usr/local/mysql/bin/mysql_config
- After that, run the build and installation script.
python setup.py build python setup.py install
ImportError: dlopen(./_mysql.so, 2): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient_r.15.dylib Referenced from: ./_mysql.so Reason: image not foundThe solution is by making a symlink from /usr/local/mysql/lib to /usr/local/mysql/lib/mysql
cd /usr/local/mysql/lib ln -s /usr/local/mysql/lib mysqlAnother error which might be occured is gcc related like the picture below: Line 47 of /usr/local/mysql/include/mysql.h is:
#include <sys/types.h>Line 93 (and 93) of /usr/include/sys/types.h is:
typedef unsigned short ushort; /* Sys V compatibility */ typedef unsigned int uint; /* Sys V compatibility */All you need to do is comment those 2 lines (dont forget to make the backup first) and do the "python setup.py build". Voila! Everything will be running well.
Read this post on my new blog