Installation and configuration of mongodb4.0 in Windows



The main contents of this paper are as follows
*What is mongodb
Installation and configuration of mongodb4.0 in Windows
We will focus on some problems encountered in the installation and configuration of mongodb4.0 in windows*

What is mongodb

Mongodb features summary: distributed file storage, easy to expand, unstructured

  1. Mongodb is a database based on distributed file storage.
  2. It is a product between relational database and non relational database, which has the most abundant functions and is most like relational database.
  3. With the growth in data volume and throughput, mongodb can easily scale without downtime and application changes.
  4. Mongodb stores data in JSON like documents, and each JSON string structure in the document may be different. Mongodb uses dynamic mode, which means that you can create records, such as the type of a field or its value, without first defining the structure.

Local installation

1. Download
Download from official website


2. Installation

  1. After opening, click next all the time, and then click the custom option in the middle to change the storage location,Note that there are no spaces in the path
  2. Pay attention to untick mongodb compass, otherwise the installation process will be very long

3. Path configuration

  1. The directory structure after installation is as follows
  2. In thedataCreate a new folder under the folderdb, inlogCreate a new file under the foldermongo.config(new file renamed)

3. InbinIn the folder is the command of mongodb. Next is the path to the configuration database. If it is windows 10, it will bring its own power shell to enter thebinIn the directory, click ‘file’ in the upper right corner of the file explorer to open the PowerShell

Input commands in the PowerShell.\mongod –dbpath D:\MongoDB\data\db(replace here with the path to your own DB folder)

4. Open in browser and visit in browserhttp://localhost:27017, the following page appears to indicate success.

Step 3 in the tutorial is actually operated in CMD, but mine is invalid in CMD. Only in the PowerShell can the instructions be executed correctly.
System does not come with a PowerShell, you can search the Internet about how to install

Configure windows services

  1. Follow the above methodbinCatalog withAdministrator statusOpen the powshell,
    And execute the following commands respectively:
    .\mongod –dbpath D:\MongoDB\data\db
    .\mongod –logpath D:\MongoDB\log\mongo.log
    .\mongod –logappend
    .\mongod –serviceName MongoDB
    .\mongod –auth
    .\mongod –install
    The database path is D: mongodbdatadb and the log path is D: mongodbdatadb MongoDBlogmongo.log , and the service name is mongodb.
  2. Input:net start MongoDB, indicating that the service was started successfully,net stop MongoDBPrompt the service to stop. Indicates that the windows service is configured successfully.


    Nuggets: comparison between mongodb and MySQL
    Rookie tutorial: mongodb tutorial
    CSDN:MongoDB4.0 Installation and service configuration under Windows