Before installing MongoDB, you must first download the MongoDB software installation package. The download address of the official website of MongoDB Community Edition: https://www.mongodb.com/download-center?jmp=nav#community
After downloading, double-click the msi installation file to install, click "Next" >>
Tick to agree to the relevant agreement, click "Next" >>
Click "Custom"-->"Browse" for custom directory installation, it is recommended to install it in C:\MongoDB, click "Next">>
Uncheck to install "Install MongoDB Compass" (otherwise it will stay in the interface of installing Compass without progress, resulting in installation failure), click "Next" >>
Click "Install" to install >>
If the following interface appears, congratulations, the installation is successful.
The difficulty of installing MongoDB is not in the installation process, but in installing the MongoDB service. The following describes how to install the MongoDB service
Before installing the MongoDB service, create two folders in the MongoDB installation directory (C:\MongoDB), one for the data folder (to store database files) and the other for the log folder (to store log files).
Create a db folder under the data folder
Create a mongo.log file in the log folder
Run CMD as an administrator and switch to the bin folder of the MongoDB installation directory
Execute the following command to install the MongoDB startup service
c:\MongoDB\bin>mongod.exe --dbpath c:\MongoDB\data\db --logpath=c:\MongoDB\log\mongo.log --logappend --install --serviceName "MongoDB"
Do not type the wrong letter, after entering it, press Enter to install
. . . Installation error, find the reason online after a minute of sadness
It turns out that MongoDB is developed in C++. To run MongoDB, the Visual C++ Redistributable Package must be installed.
Official website download address: https://www.microsoft.com/zh-CN/download/details.aspx?id=40784
If installing the Visual C++ Redistributable Package fails, make sure the operating system is patched with SP1,
The SP1 patch download address is: https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=5842
After installing the Visual C++ Redistributable Package, and then installing the MongoDB startup service, I found that no error was reported this time. Are you a little excited?
Start the MongoDB service with the following command
c:\MongoDB\bin>net start MongoDB
Or find the MongoDB service in the service to start
After starting the MongoDB service, you can connect to the MongoDB database for operation
You can add the mongodb directory (c:\MongoDB\bin) to the environment variable, so that the mongodb command line tool can be used anywhere