DEV Community

Kolade Chris
Kolade Chris

Posted on • Updated on


This article was initially published on Hashnode

MongoDB is a NoSQL database that has gained popularity in recent times. Unlike SQL databases that are like advanced spreadsheets, MongoDB stores data in JSON-like key-value pair called BSON (Binary JSON) in order to support features JSON does not.

In this article, I will walk you through the step-by-step guide on how to install MongoDB on your Windows 10 operating system, with insights on GUI tools such as Mongo Compass and Robo 3t.


STEP 1: First of all, you need to download MongoDB from the official website. You can do that here. Make sure you select msi as the package type and not zip.
Follow the installer wizard to install MongoDB.
1 (2).png

2 (2).png Select Complete as your setup type and keep the next item on default.

3 (2).png
You can choose to install Mongo Compass here; it would just take more time to install everything. My preference is to uncheck the box so I can download and install it separately.

4 (2).png
Click install.

STEP 2: Once it is done installing, navigate to C:/ProgramFiles/MongoDB/Server/4.4/bin. There, you should find Mongo.exe, mongod.exe, and mongos.exe. They are Mongo, MongoDB, and Mongo shell respectively.

5 (2).png

6 (2).png

STEP 3: Click on the address bar and type cmd to launch your windows command prompt. Click on enter and run mongo --version. You will see the version of the MongoDB installed. This means MongoDB has been rightly installed on your machine.

7 (2).png
In my case, it is version 4.4.4.

STEP 4: Next, close the command prompt and launch it in no directory this time. Run mongo --version. The response is “mongo is not recognized as an internal or external command operable program or batch file. Chill. This is because your path variable has not been assigned, meaning you have to set environment variables on your machine.

STEP 5: Search for "environment" on your machine and click “Edit the system environment variables”. You can find this in the control panel too.

8 (2).png

STEP 6: Click on environment variables.

9 (2).png

STEP 7: Under system variables, select path and click on edit.

STEP 8: In the next pop-up, click on New in order to paste your installation path. Go back to the directory where you got a proper installation response and copy the address.

10 (2).png

STEP 9: Click on New again and paste the address you copied. Hit Enter and continue clicking OK until all the boxes are closed.

11 (2).png

12 (2).png

STEP 10: Now, close your command prompt. Relaunch it and run the mongo --version. This time you should get a proper response that MongoDB has been installed correctly. Run mongod --version too to make sure the database is installed.
Forgive me for switching to Git Bash. I like to use it or Windows Subsystem for Linux (WSL).


STEP 1: To connect your command line to MongoDB, type mongo and hit enter.
If everything is done correctly so far, the mongo server should be running on port 27017 by now.

13 (2).png

STEP 2: To start using MongoDB, start by checking MongoDB default databases by running show dbs.

STEP 3: To create a database, run use firstDB. You can give it whatever name you want.

STEP 4: To create a collection, run db.<collection-name>.insert({“anything you want”: "anything you want"}). Feel free to add more. To show your collection, run show collections; your collection should show.

STEP 5: Run show dbs again to see the databases on your machine; you should see the database you created in step 3 above.

14 (2).png


To use the Mongo Compass GUI, download it here. Make sure you select the right platform for windows.
Install it, it is straightforward. Launch the Mongo compass and you should see the interface below.

15 (2).png

You might have to make some simple selections in order to see the interface above.
To connect the Mongo Compass to MongoDB, click “Fill in collection fields individually”.

16 (2).png

Leave everything the way it is and click connect and you should see the databases available on your computer.

17 (2).png

Here, you can create, insert, read, update and delete without the command line. Once you do it here, it's done globally, so if you check your collection again in the command line by running db.<collection-name>.find(), you see what you’ve done in the GUI.

18 (2).png

If you have ever used Mongo Atlas (MongoDB in the cloud), the interface is very similar to the one you see above.

As for Robo 3t, a third-party GUI tool, you can download it here.
It's simple to connect too and easier to work with than Compass, but I prefer Compass because of the Atlas-like interface.

19 (2).png

As you can see above, I have inserted my middle name and nickname with Robo 3t.

20 (2).png
Checking my database with db.person.find() gave me what you see above.

Thank you for reading.

Connect with me via my portfolio site, and Twitter via @koladechris, where I tweet and engage in anything web development.

Top comments (2)

ikeeptrying profile image

Is this supposed to work with Atlas? I.e., I've been all day following their documentation (Windows), but all I keep getting is 'mongo' is not recognized as an internal or external command, operable program or batch file. The /bin directory has a bunch of exe's, such as mongofiles.exe, mongotop.exe, mongostat.exe, but no mongo.exe or mongod.exe. Plus, none of the existing ones work from command line. And yes, I added the install directory to system PATH. Is there no way to use CLI tools for cloud-based mongo?

0348xxyyzz profile image

it save my life :))