How do I install MySQLdb?#

Download from sourceforge and extract.


$ python clean
$ python build
$ sudo python install

Mac OS X#

You may have to edit and change the line below (before building):
mysql_config.path = "mysql_config"


mysql_config.path = "/usr/local/mysql/bin/mysql_config"

Note: you have to specify the path to your mysql_config unless you have installed package for Mac.


If you get this compile error#

/usr/include/sys/types.h:92: error: duplicate ‘unsigned’  
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers  

edit the _mysql.c file and comment out this line

#define uint unsigned int


Make sure if you python is 32 bit, that your MySQL is 32 bit also.

Using virtualenv#

If you are installing MySQLdb in a virtualenv instance, it may be compiling against the system python, which may be 64-bit. Read up on Installing Python Packages.

Sources#, etc

Python - Linux - MySQL