Http://www.yzswyl.cn/blread-1444.html
Note: users are added for database operations.
1. Go to the database use dbname
2. Adding User Permissions to the current database is for the current data
1. Add and verify users
> Use admin
> Db. addUser ("zjx", "tsjianxin ")
> Db. auth ("zjx", "tsjianxin ")
2. view existing users
> Db. system. users. find ()
3. Now, you can configure a read/write permission for another database 51cv.
> Use 51cv
> Db. addUser ("51 cvrw", "51cv ")
... "ReadOnly": false...
4. configure a read-only user
> Use 51cv
> Db. addUser ("51cvr", "51cv", true)
> Db. system. users. find ()
... "ReadOnly": true...
5. delete a user
> Use dbname (admin or 51cv, etc)
> Db. system. users. remove ({user: "haha "})
> Db. system. users. find ()
6. User Login database Test
For: mongod dbname-u uname-p password
Mongo admin-u zjx-p tsjianxin
/Usr/local/mongodb/bin/mongo admin-u username-p password -- port number