1. 到SourceForge(http://sourceforge.net/directory/os:linux/?q=MySQLdb)下载MySQL-python-1.2.4b4.tar.gz
2. tar xvfz MySQL-python-1.2.4b4.tar.gz
3. cd MySQL-python-1.2.4b4
4. 执行sudo python setup.py build 命令时,报错:EnvironmentError:mysql_config not found
解决办法:sudo apt-get install libmysql-dev
5. 继续执行:sudo python setup.py build
6.执行:python setup.py install
7.测试:
>>> import MySQLdb
没有报错就表示安装成功。