Auto Start MongoDB Mac OSX

Follow the instructions to install MongoDB, after that, run through the creation of the database. The default location is /data/db but if you’re using Macports to install, you can choose to install your database alongside mongodb in /opt/local/var/db/mongodb.

To start the mongo server, simply run mongodb. MongoDB doesn’t auto launch itself. To do so, we have to edit the plist and add it to LaunchDaemon.

This is based on a MacPorts installation. If you’re using Brew, your mileage might vary.

  1. Edit /Library/LaunchDaemons/org.macports.mongodb.plist. My plist file looks like this.
  2. sudo launchctl load /Library/LaunchDaemons/org.macports.mongodb.plist
  3. Restart your system
  4. Go back into terminal and run mongo. You should be able to get into the interactive Mongo shell directly.

To stop this auto-start behaviour, simply use the unload command like so: sudo launchctl unload /Library/LaunchDaemons/org.macports.mongodb.plist

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s