我需要使用 M1 在我的 MacBook 上安装特定版本的 MySQL (5.7)。
我正在尝试使用 Homebrew 来做到这一点。
brew install mysql@5.7
输出:
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 /opt/homebrew, 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="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql@5.7 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib" export CPPFLAGS="-I/opt/homebrew/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: /opt/homebrew/opt/mysql@5.7/bin/mysql.server start
在那之后,我尝试运行:
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
source .zshrc
mysql_secure_installation
并得到错误:
Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
另外,我试过: brew services start mysql@5.7
并且还得到错误:
Error: Permission denied @ rb_sysopen - /Users/vivanc/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
似乎存在与权限相关的问题。任何建议表示赞赏。
如果您遇到诸如“
Can't connect to local MySQL server through socket '/tmp/mysql.sock'
”或“The post-install step did not complete successfully MySQL
”之类的问题,并且您之前安装了以前版本的 mysql(例如 8.x),那么您可能已经到了需要清理所有内容的地步在重新安装首选版本的 mysql@x.x 之前。如果您已经访问了这些链接: Uninstall all those broken versions of MySQL and re-install it with Brew on Mac Mavericks (Coderwall) + Install MySQL 5.7 on macOS using Homebrew (github) 并且您在启动 mysql-service 时仍然遇到问题,您应该尝试同时删除
/opt/homebrew/etc/my.cnf
文件。也将其与所有相关文件一起删除! M1 Apple Silcion 机器总结,通过
brew uninstall mysql
或brew uninstall mysql@x.x
卸载后,请删除:在此之后,一切都像全新安装一样(对我而言)。希望这节省了某人的时间。