查找并确定自己需要安装的版本
brew search mysql
==> Formulae
automysqlbackup mysql-connector-c mysql@5.5
mysql mysql-connector-c++ mysql@5.6
mysql++ mysql-sandbox mysql@5.7 ✔
mysql-client mysql-search-replace mysqltuner
mysql-cluster mysql-utilities
==> Casks
mysql-connector-python mysql-utilities navicat-for-mysql
mysql-shell mysqlworkbench sqlpro-for-mysql
安装msyql@5.7
brew install mysql@5.7
# 安装成功后,会看到这样的提示
/usr/local/Cellar/mysql/5.7.9/bin/mysqld --initialize-insecure --user=comet
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
可以看到brew在安装的时候已经初始过mysql了(不用再像网上说的再执行mysql_install_db命令),且当前没有密码于是我按照它的提示,执行命令:
mysql_secure_installation
按照提示设置密码即可