Windows MongoDB Configure user rights instances _mongodb

Source: Internet
Author: User
Tags auth mongodb

MongoDB default set to No access restriction note: Research results based on Windows platform

After successfully deploying MongoDB, enter the console: \ Input command: Mongod use admin, You will find that the DB contains a system.user table, hehe, yes, this table is equivalent to the user table in MSSQL, used to store the Super administrator, then we will add a super administrator to try it. I add a super Admin user, username for Admin,password also for a DMin, that is, we added Super admin, then we will test, see if we connect again MongoDB need not prompt to enter the username, password, we first exit.

Input command: Mongod use admin

Enter the command: Show collections, view all the tables under the library, you will find that MongoDB did not prompt you to enter the username, password, it is strange, this is how it? At the beginning of the article it was mentioned that

MongoDB default is set to no permission access restrictions, that is, then we set it to require permission access restrictions, we see the effect, how to set it?

In the registry, find the MongoDB node, in its imgpath, we modify it and join-auth as follows: Mongod

Copy Code code as follows:

"D:\Program files\mongodb\bin\mongod"-dbpath e:\work\data\mongodb\db-logpath E:\work\data\mongodb\log-auth- Service

Note: Enter the system registry (Win+r-->regedit) to find [hkey_local_machine-->system-->currentcontrolset-->services--> MongoDB] Hits "ImagePath" on the right-hand list of values

Once the modifications have been completed, they enter the console again and find that the password verification is required.
Don't forget to reboot the current service.
Enter a username and password to authenticate.
Don't worry, it's not finished yet.
When you exit the window, after you start the window again, after you switch to the other library by using the use MyDatabase, look at the table below the library and find no permissions. However, the previous command to enter the Admin library, and then verify the user name and password before entering the MyDatabase library is no problem. This allows us to enter the MyDatabase library after adding the user Db.adduser (Username,password);
This allows you to enter the MyDatabase library by user name and password.

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.