MongoDB has two roles 1 dedicated to managing User 2 Management Operations 1 MongoDB installation from the official Web download MongoDB MSI file (http://www.mongodb.org/downloads), the version I currently use is 3.0.3 (window). Double-click the MSI file installation, after the installation is complete, there are the following files if you want to start quickly, you can put C:\mongodb\bin into the environment variable path. 2 Start MongoDB after the first successful installation, MongoDB does not have any users, so to start in a non-validating way, so that you can have permission to increase the user command line:Mongod--dbpath=/opt/mongodata/data mongod Default port of 270173 connect MongoDB on new command line enter MONGO connection MongoDB default connection local 127.0.0.1 Service 4 Create Admin user use ADM In Switch to admin library
Db.createuser ( { User: "Siteuseradmin", pwd: "Password", roles: [{role: "Useradminanydatabase", DB: "Admin"}] })
Create a system administrator account Siteuseradmin
Db.createuser ( { User: "Testuseradmin", pwd: "Password", roles: [{role: "Useradmin", DB: "Test"}]< c10/>})
Create an administrator account for a separate database testuseradmin 5 Create a normal user MongoDB in the above operation do not need to verify permissions, after creating the system administrator can restart the service (Turn on permission authentication) to open the command:Mongod--dbpath=/opt/mongodata/data--auth--auth Enable authentication command use test to switch to test library Db.auth (' testuseradmin ', ' password ') to verify user Db.createuser (
{
User: "User",
PWD: "123456",
Roles: [
{role: "ReadWrite", DB: "Test"}
]
}
Create user password 123456 The role has read and write permissions in the test library. Read reads, write writes ReadWrite for read-write Db.auth (' user ', ' 123456 ') to verify that the test library can be manipulated underneath the new user
MongoDB Install and manage users