I want to automatically start my MongoDB Server at startup. The command for it is
mongod --dbpath="/Users/prateek/Desktop/Mongo Database"
How do I configure this in Mac OSX El Capitan?
Note – I have installed MongoDB using Homebrew
launchdmacos
I want to automatically start my MongoDB Server at startup. The command for it is
mongod --dbpath="/Users/prateek/Desktop/Mongo Database"
How do I configure this in Mac OSX El Capitan?
Note – I have installed MongoDB using Homebrew
Best Answer
Create a file named org.mongod.user.plist in ~/Library/LaunchAgents with the content:
This requires that mongod is in your path.
If mongod is not in your path, use the whole path in the first string of the ProgramArguments array (e.g. /usr/local/Cellar/mongodb/3.2.1/bin/mongod)
If you need stdout or stderr (which can be helpful if something fails) add the following in the dict section of the plist:
Load and start mongod with:
To connect to your MongoDB database enter:
Again this requires that mongo is in your path. Otherwise use the complete path (e.g. /usr/local/Cellar/mongodb/3.2.1/bin/mongo).