Friday 13 October 2017

MongoDB Instance in Authentication Mode

I am writing this blog in continuation of my previous blog about how to run Mongo Server as service in windows, to know more please read my prev blog. In this blog, I am going to explain about how to run a server in authentication mode. I will try to keep it in my simpler word.

I assume that you have created the service which runs the mongo server in No Authentication Mode. Or you are able to connect to the server. Let’s begin with this assumption step by step.

Step 1: Connect to the server in No Authentication Mode, Please go through this blog post.

Step 2: Use Admin database by using command “use admin”.










Step 3: Create a user with “userAdminAnyDatabase” in role.
           db.createUser(
           {
             user: "sa",
             pwd: "password",
             roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
           })









Step 4: Disconnect the Mongo Db (Exit if you are using cmd prompt). In case you are using service then please stop that by clicking on stop.










Step 5: Now you can connect to Mongo DB in auth mode from my prev blog. Or create a service in authentication mode by following my previous blog.

References:

No comments:

Post a Comment