Install MongoDB on Windows: A Step-By-Step Guide

A Step by Step MongoDB Installation on Windows:

In this informative MongoDB Training Series, we discussed in detail about the Introduction to MongoDB, its common whereabouts and its history too in our previous tutorial.

In this tutorial, we will see the installation and configuration setup of MongoDB, how it does and how a beginner with no background knowledge could install it easily without getting help from anyone.

Mongodb in windowsMongodb in windows

Pre-Requisite Information On Windows

The users of Windows must know that their windows desktop has got one of the two versions i.e. 32-bit & 64-bit.

This information could be found out in the properties of one’s “My Computer” or “This PC” on their device i.e. either their windows is 32-bit or 64-bit.

Further reading =>> Is My Windows 32 bit Or 64 bit

Meanwhile, in order to check the windows version, one can also use command prompt in the way as narrated in the snippet below:

The command is C:\>wmic os get osarchitecture

Figure 1: Command To Know Windows Version

Command To Know Windows VersionCommand To Know Windows Version

After finding this out, the 32-bit windows users would follow the guide to install the version of MongoDB which supports 32-bit and vice versa. MongoDB is available in both the versions which support their respective 32-bit & 64-bit windows.

For instance, 32-bit windows users have got the advantage of having qualitative development and testing environments.

Meanwhile, if one must get into production environments, then they must have to adopt 64-bit windows, because in this case, using 32-bit would limit the data usage which would be stored in MongoDB. Therefore, the 32-bit windows version supports the MongoDB version which has the database size lesser than 2 GigaBytes.

MongoDB Download On Windows

Click on the following link to Download MongoDB On Windows

Figure 2: To Get the Download File of MongoDB from Website

To Get the Download File Of MongoDB From WebsiteTo Get the Download File Of MongoDB From Website

OR

Click on any one of the following links which suit your Windows Version.

Windows [64-bit]

Windows [32-bit]

Installation Guide On Windows

Follow the below steps to install the proposed file:

Step 1: Open the file. We have installed for 64-bit version with the name as “MongoDB-win32-x86_64-2008plus-ssl-v3.4-latest-signed”. It is saved in the Local Disk C:/, click on the file where you’ve saved it to start the wizard.

Figure 3

64-bit version - save the file64-bit version - save the file

Step 2: Click “Next“.

Figure 4

Click "Next". - 64 bit setupClick "Next". - 64 bit setup

Step 3: Tick the check box next to ‘I accept the terms in the License Agreement’ and again click on “Next“.

Figure 5

accept the terms in the License Agreementaccept the terms in the License Agreement

Step 4: Click “Complete” to install all the features of MongoDB. As for “Custom”, this option would be used to install only the specific components of MongoDB and also if a user wants to change the location of where the installation must be done.

Figure 6

Complete installation of all the features of MongoDBComplete installation of all the features of MongoDB

Step 5: Click “Install” to begin the installation drive.

Figure 7

Click "Install" to begin the installation driveClick "Install" to begin the installation drive

Figure 8

installation of driveinstallation of drive

Step 6: After the installation has been finished. Simply, click “Finish“.

Figure 9

installation has been finishedinstallation has been finished

Configuration Through Mongo Shell

After the whole installation is done, the user must configure it.

Follow the below steps:

If you use “mongo” in the command prompt without configuring it, then it would give an error. Hence, configure it first.

Step 1: Go to the local disk C and get into “Program Files“. There you’ll find a folder named “MongoDB“.

Figure 10

Locate MongoDBLocate MongoDB

Step 2: Open it and you’ll find a folder named “bin” i.e. binaries folder. You will have 15 to 17 files in it. Copy the path, as given in the snippet path i.e. C:\Program Files\MongoDB\Server\4.0\bin

Figure 11

Bin Folder in MongoDBBin Folder in MongoDB

Step 3: Open Settings and search “Path”.

The two options given below would pop up in front of you:

  1. Edit environment variable of your account
  2. Edit the system environment variable.

Figure 12

Search "Path"Search "Path"

Step 4: Click on “Edit the system environment variable” and then click on “Environment Variables“.

Figure 13

Environment VariablesEnvironment Variables

Step 5: In the Environment variable, you’ll see the path as given in the snippet. Click “Path” and then press “Edit“.

Figure 14

Edit Environment variableEdit Environment variable

Step 6: In the Path given at your system, delete the previous ones and add new “The copied path” from binaries, and click “OK”.

Figure 15

Copied PathCopied Path

Step 7: Open Command prompts and type “mongod” to start the service.

Figure 16

type "mongod" to start the service.type "mongod" to start the service.

Step 8: Write command on the command prompt “mongo” to create the connection.

Figure 17

write command to create the connectionwrite command to create the connection

Step 9: Open Command prompt with admin privileges and type: md \data\db to make a directory which would be \data\db at the same folder.

Figure 18

make a directorymake a directory

Then, Get into the folder “data“, which would be in the same folder i.e. MongoDB at C:/ and then find the file named “mongod.lock“.

Figure 19

mongod.lockmongod.lock

Step 10: Again, open Binaries i.e. “Bin” and find “mongod.cfg file”, if you find it, then copy this file and paste it in the folder named “data” which is also in the MongoDB folder in C:/. If it is not here then finding in the “data” folder might help, usually, it happens to be there.

Copy the path which is “C:\Program Files\MongoDB\Server\4.0\data” in your system.

Figure 20

open Binaries i.e. "Bin" and find “mongod.cfg file”open Binaries i.e. "Bin" and find “mongod.cfg file”

Step 11: Open Command prompt with admin privileges and write this command: mongod –config “C:\ data\mongod.cfg” –install

Press enter.

Step 12: Again type the command: net start mongoDb

The MongoDB pops up with a message “The MongoDb Service was started successfully”. You are now good on the go. MongoDB has been successfully configured.

Configuration Through Robomongo i.e. Robo 3t

To configure MongoDB with non-commercial MongoDB management tool i.e. Robo 3t, one can easily use the full command on the mongo shell during configuration.

Step 1: Download Robo 3t and launch the installer.

Figure 21

Download Robo 3tDownload Robo 3t

Step 2: Click “I agree” to agree to the End-user agreement.

Figure 22

agree to the End user agreementagree to the End user agreement

Step 3: Click “Next“.

Figure 23

install robo 3Tinstall robo 3T

Step 4: Click “Install“.

Figure 24

Robo 3T setupRobo 3T setup

Step 5: Click “Finish“.

Figure 25

Complete InstallationComplete Installation

Step 6: Launch the Application & Click “I agree” to the agreement.

Figure 26

Launch the Application & Click "I agree"Launch the Application & Click "I agree"

Step 7: Click on “Create” to create a new connection and save the address & port as it is given.

Figure 27

create a new connectioncreate a new connection

Step 8: Click On “Connect“. Once it is connected, the user could view all the databases, collections, and documents. Through UI, one can insert Documents, delete, update and find documents.

Figure 28

Click On "Connect"Click On "Connect"

Figure 29

Robo 3TRobo 3T

Step 9: Open Command prompt with admin privileges and type: md \data\db in order to make a directory which would be \data\db at the same folder.

Figure 30

make a directorymake a directory

MongoDB would create the database directly at the same folder or location as it would be the default location of MongoDB to store information. It is done to make sure that MongoDB would find the directory at the same location when it would start.

The data import through Robo 3t is done and could be seen by using the mongoimport command with some data to be stored.

Conclusion

These are the steps to get MongoDB installed in your system.

In the above installation, the latest version of MongoDB software has been installed from the website. A user must be sure about the version which has to be the latest one.

We have now successfully installed the NoSQL MongoDB.

Check out our upcoming tutorial to know more about Create and Insert Database in MongoDB!!

PREV Tutorial | NEXT Tutorial