new user in mongodb

50 views
Skip to first unread message

megha garg

unread,
Oct 9, 2014, 4:53:15 AM10/9/14
to mongod...@googlegroups.com
I want to create a new user who can access( read/write) on a single database but not view other databases.

I am running the following command to create user:-

   db.createUser({user:"user1",pwd:"user1",roles:[{ role: "read", db: "db1" }];

When I authenticate with user1 user then I am able to insert documents in db1 collections and also in other database also. 

What is the correct query to grant access on a single database only?

Thanks in advance.


Will Berkeley

unread,
Oct 9, 2014, 11:55:12 AM10/9/14
to mongod...@googlegroups.com
Are you sure you ran the right command? The one you have in the email is not correct syntax because there is a missing }) before the terminal semicolon. When I put in an otherwise identical createUser operation and log in as user1, I see the proper behavior - I can read from db1 collections, but I cannot write to db1 or read/write from other databases.

-Will

megha garg

unread,
Oct 10, 2014, 1:30:53 AM10/10/14
to mongod...@googlegroups.com
Sorry that was a typo. I ran the correct command.

Also I am attaching the screenshot of the steps i followed.

Please correct me if I did something wrong.
user_add.png
Reply all
Reply to author
Forward
0 new messages