CentOS下python-mysqldb安装
日期:2011-04-17 | 来源:未知 | 作者:redice | 869 人围观 | 1 人鼓掌了!
(1)pyhton shell下导入MySQLdb失败。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183137_1.gif)
(2)下载解压MySQL-python。
http://pypi.python.org/pypi/MySQL-python/#downloads
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183246_1.gif)
(3)build时提示缺少setuptools。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183343_1.gif)
PS:build时我还遇到过提示“mysql_config not found”的问题。
解决方法:
使用whereis mysql命令找到mysql安装目录,假设mysql安装在/usr/local/mysql,回到MySQLdb源码目录.vi setup_posix.py编辑该文件。
找到mysql_config.path 一行,改为mysql_config.path = "/usr/local/mysql/bin/mysql_config"即可。
(4)下载安装setuptools。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183445_1.gif)
(5)测试导入setuptools成功(证明setuptools安装成功)。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183536_1.gif)
(6)build mysqldb成功。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183602_1.gif)
(7)安装 mysqldb成功。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183629_1.gif)
(8)测试导入mysqldb成功。
![](http://www.redicecn.com/uploads/allimg/110417/2_110417183659_1.gif)