1. Create a Super User
use admindb.createUser( { user: "adminUserName", pwd: "userPassword", roles: [ { roles: "userAdminAnyDatabase", db: "admin" } ] })
There are two types of superuser role, useradmin or useradminanydatabase (more access to all databases than the previous one).
DB is the name of the specified database, and admin is the management database.
2. Log in with the newly created user
--host xxx -u adminUserName -p userPassword --authenticationDatabase admin
3. View the permissions of the current user
db.runCommand( { usersInfo:"userName", showPrivileges:true })
4. Create a general user, also use CreateUser
use db01db< Span class= "Hljs-class" >.createuser ({ user: "OneUser", Pwd: "12345", roles:[{role: "read", Db:{role: "read", Db: "DB02"}, { role: " Read ", Db:" DB03 "}]})
5. Create a superuser who is not restricted by access
use admindb.createUser( { user:"superuser", pwd:"pwd", roles:["root"] })
6. Change the password
use admindb.changeUserPassword("username", "xxx")
7. View user Information
db.runCommand({usersInfo:"userName"})
8. Change Password and user information
db.runCommand( { updateUser:"username", pwd:"xxx", customData:{title:"xxx"} })
Note:
1. and user management related operations are basically to run under the Admin database, to use the admin first;
2. If under a single database, it can only operate on the permissions of the current database;
3. Db.adduser is an older version of the operation, now the version can also continue to use, created by the user is a root role of the Super administrator.
MongoDB Getting Started tutorial of the MongoDB database installation diagram under Windows
About the benefits of MongoDB, the advantages and so on here is not to say, the only thing to tell is that MongoDB has three-dimensional: Database, collection, document, which is the corresponding relational database table, the text
MongoDB Beginner's Guide to the MongoDB database of additions and deletions to check the operation
Read the previous article, I believe everyone will know how to open MongoDB, this article on the next one of the additions and deletions to change, first when we use the same way to open MongoDB, suddenly dumbfounded, wipe, unexpectedly open
Introduction to the aggregation and cursor operations for the MongoDB Getting Started tutorial
Today, I would like to share with you the more interesting knowledge of MongoDB, including: aggregation, cursor. One: Aggregation common aggregation operations are the same as SQL Server: Count,distinct,group,mapreduce. 1countc
Http://www.gimoo.net/t/1410/542bafd1970b9.html
A brief analysis of MONGODB user management