How to create read only user on Mongodb

We can use the following way to create read only user in Mongodb.

Step1: Login to Mongodb as admin user

Step2: Run the following query to create user.

>db.createUser({user: "username", pwd: "password", roles: [{role: "read", db: "database"}]});

Here username, password and database should be replaced with the corresponding values.

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *