Windows installs MongoDB 4.0 and gives users access rights

Source: Internet
Author: User
Tags install mongodb mongodb compass

The first part of Windows installation MongoDB-4.0

First step: Download mongodb:https://www.mongodb.com/download-center?jmp=nav#community

I am currently using the version Mongodb-win32-x86_64-2008plus-ssl-4.0.1-signed.msi

Step two: Download the Community edition Compass:https://www.mongodb.com/download-center?jmp=nav#compass

Step three: Install MongoDB: Be sure to check "Install MongoDB Compass" when installing

If you don't remove the checkmark, the page will be stuck in this place.

Fourth Step: Add your path to the environment variable by installing the bin directory of MongoDB; for example: C:\Program files\mongodb\server\4.0\bin

CMD to open the console and enter MONGO carriage return, you can enter the MongoDB shell and enter show DBS to see the database. Indication of successful installation;

The second part gives the user access rights

After the installation is complete, MongoDB defaults to native access and does not require a password; The following we add users and turn on remote services;

First step: Open cmd input mongo into MongoDB; Create test database

Use test

Step Two: Create a new Zhangsan user in the test user

Db.createuser ({User: "Zhangsan", pwd: "Zhangsanpwd", roles: [{role: "Dbowner", DB: "Test"}]})

Step Three: Modify the configuration file in the MongoDB installation directory Bin/mongod.cfg

Modify the default BINGIP in 127.0.0.1 to 0.0.0.0, where other network segment addresses can be connected; (never comment, otherwise the service may not start)

Remove the comment for #security:, and then add the authorization:enabled #注意authorization前面要有两个空格

Fourth step: Restart the MongoDB service open a new console and enter the following command in turn. If startup fails, you should check the Mongod.cfg file

net stop MongoDB

net start MongoDB

Fifth Step: Test

MONGO 127.0.0.1:27017/test-u zhangsan-p zhangsanpwd

Login successful

Complete

Windows installs MongoDB 4.0 and gives users access rights

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.