brew start 和brew restart 不会启动服务

mra*_*teb 11 mysql macos homebrew

我使用brew安装了mysql@5.7。安装后,我使用 启动了服务brew services start mysql@5.7。检查使用brew services表明其工作正常。

但在第一次之后的任何尝试中,行为都是不同的。我运行brew services start mysql@5.7并得到:

Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/505 /Users/Mahmoud/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist` exited with 5.
Run Code Online (Sandbox Code Playgroud)

如果我然后尝试重新启动服务,使用brew services restart mysql@5.7我得到

Stopping `mysql@5.7`... (might take a while)
==> Successfully stopped `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)
==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)
Run Code Online (Sandbox Code Playgroud)

但使用检查brew services会显示该服务已停止:

Name      Status  User File
mysql@5.7 stopped root ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
Run Code Online (Sandbox Code Playgroud)

手动停止服务brew services stop mysql@5.7并重新启动也不起作用。

也尝试过卸载使用brew uninstall mysql@5.7并重新安装使用brew install mysql@5.7,但问题仍然存在。我尝试环顾四周,但没有看到有人遇到同样的问题。有想法该怎么解决这个吗?

jaq*_*ick 37

环境:M1 MPB、OSX 12.4

花了一整天的时间,终于找到了可行的解决方案。

停止服务brew services stop mysql@5.7

删除启动代理文件rm ~/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist

如果服务已链接,则取消链接brew unlink mysql@5.7

卸载服务brew uninstall mysql@5.7

然后我删除了上面建议的 mysql 数据目录。这不在/usr/local/var/mysql我的机器上,而是/opt/homebrew/var/mysql

所以rm -rf /opt/homebrew/var/mysql

这不是我的最后一步。此时重新安装给了我一堆错误,并且brew安装后步骤失败了。大多数错误都指向我的my.cnf文件。我发现在尝试重新安装之前删除此文件可以防止这些错误。

我对此文件进行了备份,以防万一这会导致更多问题。

cp /opt/homebrew/etc/my.cnf /opt/homebrew/etc/my.cnf.backup

然后,rm /opt/homebrew/etc/my.cnf

注意:此文件可能位于您计算机上的不同位置。

好的,现在进行全新安装。

brew install mysql@5.7

brew link mysql@5.7 --force

如果链接该包,您可以按照brew日志建议将其添加到您的路径中。因此,将, 添加export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"到您的~/.zshrc.

brew services list使用或验证服务是否可用brew services

如果您在那里看到 mysql@5.7,请继续并启动它brew services start mysql@5.7

  • 这对我不起作用。M1 Pro,操作系统:Ventura 13.2.1。错误:`❯brew services start mysql@5.7 引导失败:5:输入/输出错误尝试以 root 身份重新运行该命令以获得更丰富的错误。错误:执行失败;`/bin/launchctl bootstrap gui/501 /Users/mariusz/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist` 退出并显示 5。` (4认同)
  • 这位帮我解决了,谢谢! (3认同)