# 1. 查看需要安装的版本
brew search mysql
# 2. 指定版本安装
brew install mysql@5.7
# 3. 如果安装遇到问题(总结), 没有遇到跳过下一步
# 执行下面2个命令. 有个前提,很多人更换了 shell. 比如我用的 Fish 要切换成 bash 在执行 不然会报错
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/man/man8
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man8
# 4. 处理玩问题继续执行安装命令
# 5. 配置环境变量
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
# 6. 启动服务
mysql.server start
brew services start mysql@5.7
# 7. 初始化,设置密码,进行一些设置
mysql_secure_installation