You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Homebrew启动mongodb-community@5.0失败:Bootstrap报I/O错误

MongoDB Community 5.0启动失败(Bootstrap failed: 5: Input/output error)排查与解决

我通过Homebrew安装了mongodb-community@5.0,执行mongod --version可正常返回对应版本信息,但执行brew services start mongodb-community@5.0时触发错误:

Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; /bin/launchctl bootstrap gui/502 /Users/<user>/Library/LaunchAgents/homebrew.mxcl.mongodb-community@5.0.plist exited with 5.

配置详情

.zshrc 文件内容

export PATH=/opt/homebrew/bin:$PATH
export PATH="/opt/homebrew/opt/mongodb-community@5.0/bin:$PATH"
export PATH="/opt/homebrew/opt/mongodb-community@5.0/bin:$PATH"

mongod.conf 文件配置(位于/opt/homebrew/etc/mongod.conf,M1芯片)

destination: file
  path: /opt/homebrew/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /opt/homebrew/var/mongodb
net:
  bindIp: 127.0.0.1, ::1
  ipv6: true

解决步骤

  • 检查目录权限
    日志和数据目录权限异常是触发I/O错误的常见原因,执行以下命令修复:

    sudo chown -R $(whoami) /opt/homebrew/var/log/mongodb
    sudo chown -R $(whoami) /opt/homebrew/var/mongodb
    
  • 重建LaunchAgent配置文件
    删除损坏的plist文件后重新生成:

    rm /Users/<user>/Library/LaunchAgents/homebrew.mxcl.mongodb-community@5.0.plist
    brew services restart mongodb-community@5.0
    

    注意将命令中的<user>替换为你的实际系统用户名。

  • 手动启动验证配置
    先跳过brew services,手动启动mongod确认配置有效性:

    mongod --config /opt/homebrew/etc/mongod.conf
    

    如果手动启动成功,说明是brew的服务配置问题,重新执行brew services start mongodb-community@5.0即可。

  • 简化PATH配置
    .zshrc中重复添加了MongoDB的PATH项,可简化为以下内容,再执行source ~/.zshrc生效:

    export PATH=/opt/homebrew/bin:$PATH
    export PATH="/opt/homebrew/opt/mongodb-community@5.0/bin:$PATH"
    

内容的提问来源于stack exchange,提问作者Aman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 08:43:32