在 macOS 上安裝 MySQL 5.7
安裝 Homebrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝 MySQL
在編寫文章時,Homebrew 默認使用 MySQL8 版本,但由於我們的目標是獲得 5.7 版本,因此需要將 @5.7 附加到默認的包密鑰中:
輸入以下命令安裝 MySQL5.7
$ brew install mysql@5.7
其他配置
安裝 brew services
$ brew tap homebrew/services
開啟 MySQL 服務
$ brew services start mysql@5.7
檢查 MySQL 是否成功加載
$ brew services list
強制鏈接 5.7 版本
$ brew link mysql@5.7 --force
檢查 MySQL 版本
$ mysql -V
初始化設置 root 密碼
mysql_secure_installation
登錄
mysql -uroot -p
參考鏈接:
https://gist.github.com/operatino/392614486ce4421063b9dece4dfe6c21