通过brew 安装MySQL5.7
#查看brew已安装的
brew install list
#搜索mysql可以安装的版本 brew install mysql是安装的8.0版本
brew search mysql
brew install mysql@5.7
安装后的信息
==> Reinstalling mysql@5.7
==> Downloading https://homebrew.bintray.com/bottles/mysql@5.7-5.7.26.mojave.bot
Already downloaded: /Users/onefiter/Library/Caches/Homebrew/downloads/665d7cef7caaddc43ad93397ebb4a9cf1737a905403381440be05956e06e35a2--mysql@5.7-5.7.26.mojave.bottle.tar.gz
==> Pouring mysql@5.7-5.7.26.mojave.bottle.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mysql@5.7 first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql@5.7 you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
To have launchd start mysql@5.7 now and restart at login:
brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@5.7/bin/mysql.server start
==> Summary
🍺 /usr/local/Cellar/mysql@5.7/5.7.26: 320 files, 231.8MB
对MySQL进行配置
设置密码
#设置密码以及删除一些账户
mysql_secure_installation
注:
若之前有安装过MySQL,请删除rm -rf /usr/local/var/mysql
再进行安装brew install mysql@5.7