在Python安装MySQL支持模块的方法


刚安装Python的MySQL支持库,一口气遇到了一连串的问题,好在Google一下,均解决。遂记录下,备忘。

1.下载Python的MySQL支持库

地址:http://sourceforge.net/projects/mysql-python/

2.解压编译

python setup.py install

遇到第一个问题:

_mysql.c:44:23: error: my_config.h: No such file or directory

解决办法,编辑setup_posix.py文件,将mysql_config.path设置成你安装的mysql的目录,比如/usr/local/mysql/bin/mysql_config

3.在python中"import MySQLdb",遇到问题:

ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

解决办法,编辑/etc/ld.so.conf.d/mysql-i386.conf文件

改成正确的mysql安装地址,比如我的:usr/local/mysql/lib/mysql

存盘后退出,执行ldconfig

4.搞定,打完收工
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3