How to set users for my Database.

19 views
Skip to first unread message

Munavar Fairooz C

unread,
Apr 23, 2015, 2:46:54 AM4/23/15
to mongo...@googlegroups.com
I'm using mongoDB without any authentication now. just start mongod in one teminal and mongo in other. I want to set a group of users to a  my database. Only that users should able to do the specified roles like write documents into collection, read from existing collections etc.. No other user can access that database. 
here is what i done so far. 
use admin
db.createUser(
  {
    user: "siteUserAdmin",
    pwd: "password",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

use hospital
db.createUser(  {
    user: "hospitalUser",
    pwd: "password",
    roles: [ { role: "read", db: "hospital" } ]
  }
)


But still i'm still able to write documents into hospital collection even though i assigned read permission only.

Can anyone explain me in details what should i do to solve my problem??
thankyou..


Amalia Hawkins

unread,
Apr 23, 2015, 10:43:48 AM4/23/15
to mongo...@googlegroups.com
Hi, Munavar --

You mentioned that you are using MongoDB without authentication. However, in order for MongoDB to check user permissions, you need to run the MongoDB server with authorization turned on. You can enable authorization using the --auth or the --keyFile options, or if using a configuration file, with the security.authorization or the security.keyFile settings.

Please also note that this mailing list is intended for developers of MongoDB. Please use the https://groups.google.com/forum/#!forum/mongodb-user for your questions instead.

I hope this helps.
Amalia

--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-dev.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages