This article by larrylgq prepared, reproduced please note the Source: http://blog.csdn.net/larrylgq/article/details/7395261
Author: Lu guiqiang
Email: larry.lv.word@gmail.com
MongoDB adds user authentication: adds users, deletes users, modifies user passwords, reads and writes, and read-only permissions.
Note: Adding users is for database operations.
Take creating a Java User (whose password is Java) in the QA database as an example.
> Use QA // enter the database QA
> DB. adduser ("Java", "Java") // Add a user to the current database
> DB. Auth ("Java", "Java") // Add a user to the current database and verify
> DB. adduser ("Java", "Java", true) // configure a read-only user
> DB. system. Users. Find () // view existing users
> DB. system. Users. Remove ({User: "Java"}) // delete a user from the current database
Mongod pa-u Java-P Java // log on to the database