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

MacOS Mojave 10.14.5下mongodb-community的mongod命令启动失败求助

Troubleshooting MongoDB Startup Failure on macOS Mojave 10.14.5

Hey there, let’s work through this MongoDB startup issue step by step— I’ve run into similar snags on Mojave before, so here are actionable fixes to try:

1. First, Grab the Exact Error Details

Since we don’t have access to your screenshot, let’s pull the official error logs to pinpoint what’s going wrong:

  • Run MongoDB with explicit logging enabled to capture detailed issues:
    mongod --logpath /var/log/mongodb.log --logappend
    
  • Open the log file with cat /var/log/mongodb.log or your preferred text editor. Common culprits here include permission mismatches, port conflicts, or missing required directories.

2. Double-Check /data/db Permissions

Even though you’ve set ownership, let’s verify and fix potential gaps:

  • First, confirm the current ownership of the directory:
    ls -ld /data/db
    
    You should see dhruvbansal listed as both the owner and group (usually wheel for Mac user accounts).
  • If you ever ran mongod with sudo in the past, the files inside /data/db might now be owned by root. Fix this with:
    sudo chown -R dhruvbansal:wheel /data/db
    
  • Pro tip: Avoid running mongod with sudo unless absolutely necessary— it creates permission conflicts between root and your regular user account. Stick to running it as your standard user.

3. Check for Port Conflicts

MongoDB uses port 27017 by default— if another process is hogging this port, MongoDB can’t start:

  • Check what’s using the port:
    lsof -i :27017
    
  • If you see a process listed, kill it with:
    kill -9 <PID>
    
    (Replace <PID> with the process ID from the lsof output.)
  • Alternatively, test starting MongoDB on a different port to rule out conflicts:
    mongod --port 27018
    

Since you installed MongoDB via Homebrew, using Brew’s built-in service manager simplifies startup and avoids manual config headaches:

  • Start MongoDB as a background service:
    brew services start mongodb-community
    
  • To stop it later:
    brew services stop mongodb-community
    
  • Check the service status at any time:
    brew services list
    
    This method automatically uses the default config file at /usr/local/etc/mongod.conf and handles permissions correctly out of the box.

5. Verify the Default Config File

If you prefer manual startup, check the Brew-installed config at /usr/local/etc/mongod.conf:

  • Ensure the dbPath setting points to /data/db (it should by default).
  • Double-check for typos or invalid settings that might block the daemon from starting.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 18:07:59