How to secure MongoDB with username and password

You need to start mongod with the --auth option after setting up the user.

From the MongoDB Site:

Run the database (mongod process) with the --auth option to enable
security. You must either have added a user to the admin db before
starting the server with --auth, or add the first user from the
localhost interface.

MongoDB Authentication

Leave a Comment