今天安装mysql-pyhon,发现一直安装不上,报的是以下错。最后发现是以前偷懒埋的坑,报的错是以下fatal error: 'my_config.h' file not found。
坑是以前在装mysql server时安装社区版本打不开,偷懒安装了开发版少了组件。卸载当前的开发版并安装社区版本后正常。
需要安装下面版本:https://dev.mysql.com/downloads/mysql/
卸载方法 系统偏好设置中停止mysql服务并删除mysql服务图标,清除以下文件
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
其它注意:如果报mysql_config: No such file or directory
下载源安装文件:https://pypi.python.org/pypi/MySQL-python/1.2.5
#查找当前系统文件位置如我的电脑是/usr/local/mysql-5.7.21-macos10.13-x86_64/bin/mysql_config
wsf535MacBook-Air:111 wsf535$ sudo find / -name mysql_config
Password:
/usr/local/mysql-5.7.21-macos10.13-x86_64/bin/mysql_config
#修改mysql-python源文件下的site.cfg,新增下面行
mysql_config = /usr/local/mysql-5.7.21-macos10.13-x86_64/bin/mysql_config
启动MySQL服务
sudo /usr/local/MySQL/support-files/mysql.server start
停止MySQL服务
sudo /usr/local/mysql/support-files/mysql.server stop
重启MySQL服务
sudo /usr/local/mysql/support-files/mysql.server restart
网友评论