记一次Mac brew service start失败

起因

想要启动postgresql服务,使用命令brew service start postgresql@14报错

~% brew services start postgresql@14
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/lucky/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist` exited with 5.

尝试

  1. 根据提示使用sudo重新运行命令,想看一下更详细的错误,但是sudo启动成功
    ~ % sudo brew services start postgresql@14
    Password:
    Warning: Taking root:admin ownership of some postgresql@14 paths:
      /opt/homebrew/Cellar/postgresql@14/14.9/bin
      /opt/homebrew/Cellar/postgresql@14/14.9/bin/postgres
      /opt/homebrew/opt/postgresql@14
      /opt/homebrew/opt/postgresql@14/bin
      /opt/homebrew/var/homebrew/linked/postgresql@14
    This will require manual removal of these paths using `sudo rm` on
    brew upgrade/reinstall/uninstall.
    Warning: postgresql@14 must be run as non-root to start at user login!
    ==> Successfully started `postgresql@14` (label: homebrew.mxcl.postgresql@14)
    
    但是仍然无法连接postgresql。
  2. 查到有可能是因为端口被占用。但是并不是。
  3. 再次尝试运行sudo brew services start postgresql@14,报错已经在运行,这里猜测pg是根据用户进行管理的,在root用户下启动的服务普通用户无法连接(未经证实)。然后运行sudo brew services stop postgresql@14

解决

尝试运行了一下brew services stop postgresql@14,竟然返回运行成功,之后再启动pg就成功了。

总结

误打误撞解决了问题,但是并不理解为什么。以及pg对不同用户的管理方式也需要再去学一些。
对于报错

Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/lucky/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist` exited with 5.

github上也有很多问答,但是没怎么细看,好像更多是就事论事,存在很多情况。

Update

启动了postgresql仍然无法连接,而且我发现如果重复启动也会报上面的错误,所以我怀疑最开始问题就不是无法启动,而是无法连接。看到了这样一篇blog,https://blog.csdn.net/qq_36840228/article/details/125724652,解决了问题,学习ing

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值