Homebrew安装指定版本Mysql(以5.7为例)

安装Homebrew

Homebrew官网:https://brew.sh/
安装途中可能遇到connection refused 问题,可看本人之前发的教程解决

搜索可安装版本

$ brew search boost

修改环境变量

brew安装的东西都是在

/usr/local/Cellar/

本人的路径是:

/usr/local/Cellar/mysql@5.7/5.7.23/bin

mysql版本不同,路径会有一些不同

终端输入命令

sudo vim .bash_profile

按i进入insert模式,输入:

export PATH=$PATH:/usr/local/Cellar/mysql@5.7/5.7.23/bin

然后esc退出insert模式,并在最下方输入:wq保存退出。
(注意“wq”前有个“:”)

生效配置文件

source .bash_profile

回车执行,运行环境变量。

自动生效配置文件

如果没有这一步,那么每次关掉终端在打开都需要重新source .bash_profile。首先,

vi ~/.zshrc

输入:

export PATH=${PATH}:/usr/local/Cellar/mysql@5.7/5.7.23/bin

保存后

source ~/.zshrc

评论