1、首先從sourceforge下載安裝:
cd /usr/local/src/ wget http://nchc.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
2、解壓縮文件:
tar xzvf MySQL-python-1.2.2.tar.gz cd MySQL-python-1.2.2
3、安裝:
這裡需要注意的是需要修改幾個文件
export LD_LIBRARY_PATH=/usr/local/mysql/lib/mysql ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so /usr/lib/libmysqlclient.so.14 ldconfig (這個用來加載so模塊的)
4、build和install
python setup.py build python setup.py install
5、使用
python import MySQLdb