Mac Python3安装MySQL问题记录

2017-11-02 18:51:36来源:CSDN作者:hyq912人点击

分享
第七城市th7cn

Mac如何安装MySQL:

去MySQL官网下载最新的MySQL社区版https://dev.mysql.com/downloads/mysql/

不断下一步,直到安装成功,在【系统偏好设置】中找到【MySQL】,进入后点击【Start MySQL Server】开启MySQL服务


提示-bash: mysql: command not found的解决方法:

vim ~/.bashrc

在文件末尾加入:

alias mysql=/usr/local/mysql/bin/mysqlalias mysqladmin=/usr/local/mysql/bin/mysqladmin

执行命令:

vim ~/.bash_profile

在文件末尾加入:

source ~/.bash_profile

重启终端即可


pip安装mysqlclient失败(mysql_config not found)的解决方法

报错信息:

WodeMacBook-Pro:~ macbook$ pip3 install mysqlclientCollecting mysqlclient  Using cached mysqlclient-1.3.12.tar.gz    Complete output from command python setup.py egg_info:    /bin/sh: mysql_config: command not found    Traceback (most recent call last):      File "<string>", line 1, in <module>      File "/private/var/folders/42/nrhy_y6s3sd_ykgm16lpbcjm0000gn/T/pip-build-m7lqcyxa/mysqlclient/setup.py", line 17, in <module>        metadata, options = get_config()      File "/private/var/folders/42/nrhy_y6s3sd_ykgm16lpbcjm0000gn/T/pip-build-m7lqcyxa/mysqlclient/setup_posix.py", line 44, in get_config        libs = mysql_config("libs_r")      File "/private/var/folders/42/nrhy_y6s3sd_ykgm16lpbcjm0000gn/T/pip-build-m7lqcyxa/mysqlclient/setup_posix.py", line 26, in mysql_config        raise EnvironmentError("%s not found" % (mysql_config.path,))    OSError: mysql_config not found    ----------------------------------------Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/42/nrhy_y6s3sd_ykgm16lpbcjm0000gn/T/pip-build-m7lqcyxa/mysqlclient/

执行命令:

ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config

将mysql_config链接到/usr/local/bin目录下,再次使用安装命令即可


第七城市th7cn

微信扫一扫

第七城市微信公众平台