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