Setting up a Launch Daemon for MongoDB on Mac OS X

Step 1:
Create a new .plist at /Library/LaunchDaemons/org.mongo.mongod.plist.

Step 2:
Add the below XML to the .plist created above and save.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
<plist version="1.0">

Step 3:
Run the below in Terminal if you haven’t already created a mongodb log and database directory when you installed mongodb:

$ sudo touch /var/log/mongodb.log
$ sudo mkdir /var/lib/mongodb

Step 4:
Run the below in a Bash shell:

$ sudo chown root:wheel /Library/LaunchDaemons/org.mongo.mongod.plist
$ sudo launchctl load /Library/LaunchDaemons/org.mongo.mongod.plist
$ sudo launchctl start org.mongo.mongod