Here is a quick post on using mongodb for a problem I face occassionally! (actually more often than I'd expect!)

Starting mongodb custom configuration

I typically start mongodb on my Macbook using the following command which is setup for authorization etc.

mongod --config /usr/local/etc/mongod.conf

The config file is as follows:

storage:
  dbPath: /Users/santosh/data/db
net:
  bindIp: 127.0.0.1
security:
  authorization: enabled

It basically sets up the directory for storage, bind the service to be accessible locally (i.e not exposed by default) and has authorization enabled.

Starting mongodb without authetication

At times, I have the need to run mongodb without authentication to speed up few toy projects.

My typical procedure so far used to be to go the conf file, set authorization to false and then start the server. This is cumbersome!

Go back revert the changes, etc. ... back and forth!

This is a PITA ... until now.

Starting the server with custom parameters is straight-forward as mentioned here.

The following command does the job for me! ;-)

mongod --dbpath "/Users/santosh/data/db"