升级macOS Big Sur后Homebrew启动mongodb-community报Bootstrap failed 5错误
macOS 11.5.2(Big Sur)brew启动MongoDB报错Input/output error解决方案
该报错多由系统升级后MongoDB数据目录权限异常、数据文件损坏或launchctl服务注册残留导致,可按以下步骤依次排查修复:
修复步骤
- 清理现有残留服务
执行以下命令停止异常服务并清除注册项:brew services stop mongodb-community launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist - 修复数据目录权限
Intel芯片Mac默认数据目录为/usr/local/var/mongodb,M1/M2芯片Mac默认路径为/opt/homebrew/var/mongodb,可先查看配置确认路径:
替换下方命令中的# Intel芯片执行 cat /usr/local/etc/mongod.conf | grep dbPath # M1/M2芯片执行 cat /opt/homebrew/etc/mongod.conf | grep dbPath<实际dbPath路径>后执行权限修复:sudo chown -R $(whoami) <实际dbPath路径> - 删除损坏的锁文件
异常退出会导致mongod锁文件损坏,直接删除即可:rm <实际dbPath路径>/mongod.lock - 修复损坏的数据库文件
系统升级过程可能导致数据文件一致性异常,执行修复命令:mongod --repair --dbpath <实际dbPath路径> - 重新启动服务
brew services start mongodb-community - 验证修复结果:
执行brew services list,若mongodb-community状态显示为started即为修复成功,可正常连接数据库。
特殊情况处理
若以上步骤执行后仍报错,可直接删除损坏的plist注册文件后重启服务:
rm ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist brew services restart mongodb-community
内容的提问来源于stack exchange,提问作者dasqueel
相关产品推荐
相关产品推荐

