Windows MongoDB Permissions Setting workaround

Source: Internet
Author: User

About MongoDB:

MongoDB is a cross-platform, document-oriented database that provides high performance, high availability, and scalability convenience. MongoDB works on the concept of collection and documentation.

MongoDB defaults to no access restrictions, so you can go directly into the database and manipulate the data.

Event background: Recently, the company placed in the mobile room of the two servers equipped with MongoDB database is scanned by the Green Alliance has a loophole, asked us to solve

The solution provided by the Green Alliance is to add any user to the Admin library and enable authentication. But the Green league method is based on Linux, but in fact the principle is similar.

I search the article more on the Internet, to integrate the actual situation of the application of our project, here to record, in order to forget.

Step1: After switching to the bin directory of the MongoDB installation path, perform MONGO login.

SETP2: Use show dbs to directly view the databases that already exist on the system.

Step3: Enter the admin library

STEP4: Create user command as follows:

db.createUser(          user "admin"      pwd:  "admin123"      roles: [ { role:  "userAdminAnyDatabase" , db:  "admin" } ]     )

STEP5: Enter the system registry (Win+r-->regedit) to find the [hkey_local_machine-->system-->currentcontrolset-->services--> MongoDB] hit "ImagePath" in the value list on the right to add--auth

STEP6: Restart MongoDB service:

STEP7: Re-entry into view existing database discovery does not have permission

STEP8: Authentication, direct authentication prompt failure (because MongoDB users are library-based, you must specify a database before you can authenticate)

STPE9: Enter the admin library, and authenticate, return 1 for authentication success, and can view the database;

But it also leads to a problem, "MongoDB is not available for integrated systems."

Since the integrated system is used directly on the MONGDB, without authentication, the integrated system can no longer use MongoDB after authentication is enabled.

Windows MongoDB Permissions Setting workaround

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.