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.