MongoDB default boot is no authentication, and no account, as long as the service can be connected to the database for a variety of operations, this can not. Now, we have to start with user and authentication step-by.
In the first step, we have to locate the MongoDB installation directory. I am the C:\mongodb of this machine.
Then press SHIFT right-click on the space in the window and you will see an option to "Open command Window Here", the average person I don't tell him ^ ^. Within CMD we use the following command
Mongod--auth--logpath "D:\Program files (x86) \web\mongodb\log\log.log"--logappend--dbpath "D:\Program files (x86) \ Web\mongodb\data\db "--directoryperdb--reinstall
Re-install MongoDB service, add--auth is to tell MONGO we want to turn on user rights authentication. After the installation service is complete, start the database using net start MongoDB.
The second step is to use the command in cmd in the root directory of the MONGO
> MONGO
MongoDB Shell version:2.2.0
Connecting To:test
> Use admin
Switched to DB admin
> Db.adduser ("Root", "123456")
{"n": 0, "ConnectionID": Ten, "err": null, "OK": 1}
{
"User": "Root",
"ReadOnly": false,
"pwd": "B7BA7B1291CE2EC8AF3099B8F55844A1",
"_id": ObjectId ("4f8a558000ab5a9a630c0d31")
}
OK, so we set up the Super Administrator's account and password.
The third step, login authentication
> Db.auth ("Root", "123456")
Fourth step, query the user who has been added
> Db.system.users.find ()
{"_id": ObjectId ("4f8a558000ab5a9a630c0d31"), "user": "Root", "readOnly": false, "pwd": "b7ba7b1291ce2ec8af3099b8f558 44A1 "}
At this point, the super-managed account has been added successfully, the other database is the same operation.
MongoDB Add Users and certifications