What is the correct way to start a mongod service on linux / OS X?
Edit: you should now use brew services start mongodb
, as in Gergo's answer...
When you install/upgrade mongodb, brew will tell you what to do:
To have launchd start mongodb at login:
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod
It works perfectly.
With recent builds of mongodb community edition, this is straightforward.
When you install via brew, it tells you what exactly to do. There is no need to create a new launch control file.
$ brew install mongodb==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.0.6.yosemite.bottle.tar.gz ### 100.0%==> Pouring mongodb-3.0.6.yosemite.bottle.tar.gz==> CaveatsTo have launchd start mongodb at login: ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgentsThen to load mongodb now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plistOr, if you don't want/need launchctl, you can just run: mongod --config /usr/local/etc/mongod.conf==> Summary🍺 /usr/local/Cellar/mongodb/3.0.6: 17 files, 159M
Homebrew's services
tap integrates formulas with the launchctl
manager. Adding it is easy:
brew tap homebrew/services
You can then launch MongoDB with this command (this will also start mongodb on boot):
brew services start mongodb
You can also use stop
or restart
:
brew services stop mongodbbrew services restart mongodb