1、到https://pypi.python.org/pypi/MySQL-python/1.2.3下载
2、解压进去阅读README
python setup.py build
报错 mysql_config找不到。 建议一个软链接 解决该问题 ln -s /usr/local/mysql/bin/mysql_config /usr/bin
python setup.py install
3、安装完成后发现 import MySQLdb的时候报错
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
原因是未找到相关的库
我的解决方案:
vim /etc/ld.so.conf
增加mysql库的目录(也就是libmysqlclient_r.so.15所在的目录) /usr/local/mysql/lib/mysql
保存退出,运行下 ldconfig 命令,大功告成
==================================================
或者直接用 easy_install MySQL-python (pip install MySQL-python ),这样就不存在各种依赖包问题,最是方便