MongoDB Windows Reinstall Add Auth

Source: Internet
Author: User
Tags auth install mongodb mongodb windows

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

"D:\Program Files (x86) \web\mongodb\log\log.log"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 Windows Reinstall Add Auth

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.