下载安装包:然后解压。
切换到目录下执行
python setup.py install
报错:
EnvironmentError: mysql_config not found
解决:在安装包中找到site.cfg文件,将
#mysql_config =/usr/local/bin/mysql_config
修改为:
mysql_config =/usr/local/mysql/bin/mysql_config
继续
python setup.py install
安装完毕后进入python交互模式:
import MySQLdb
报错:
Reason: p_w_picpath not found
解决:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylibsudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
之后
import MySQLdb
正常