Complete MongoDB Tutorial + Step by Step Demo with Spring Boot

In this demo, I would teach you how to set up and use MongoDB. It would be a complete MongoDB tutorial.

Watch the Video here

You will learn the following:

  1. How to Download, Install and Start MongoDB
  2. Create Database, Collections(Tables) and Documents(Records)
  3. Setup and Use MongoDB GUI Application(Studio3T)
  4. Setup and Us MongoDB Compass(GUI Tool)


1. Download, Install and Start MongoDB

The first thing you should do is to download MongoDB. Get is from this link

It downloads as a .msi installer file. Run the install to install MongoDB. Then restart your system

Then you may go to your services.msc, find and stop MongoDB.


To run MongoDB:

Open command prompt as an adminstrator

Navigate to the MongoDB bin directory.

Then run the following command:

mongod.exe --dbpath="D:\ProgramFiles\MongoDB\Server\4.2\data"

If the command runs successfully, then the server starts as shown below

Now the server have started, you can now minimize the window(Don’t Close it!)

Next, open the bin directory and run the mongo.exe file. It opens the prompt where you can start entering and executing mongoDB commands.


MongoDB Client Interface

MongoDB Client Interface


Let’s now get into the fun part!


2. Create Database, Collections and Documents

First, I would show you how to create these objects in the command line. It’s very easy. Then, we would go to download and install the GUI tool(Studio3T) and the use it.

Just to be clear: in MongoDB terms, we use Database, Collections and Documents. Here, Collections corresponds to table while Document corresponds to Records. So we would actually insert a document into a collection.

To view databases:

show dbs


Switch to a database:

use test


View collection in the database:

show collections


To create a collection and insert a document:

     name: "kindson",
     class: 2,
     division: "A",
     subjects: ["english", "science", "music"]


Update a collection, change the division to C:

  { "name" : "kindson" },
    $set: { "division": "C" }


Query a collection:



Delete a document with the name, kindson:

   { "name": "kindson" } 


Drop a collection:



3. Setup the MongoDB GUI (Studio3T)

You can download Studio3T from this link

Note: It was previously called RoboMongo

After is successfully downloads, unzip it and you will see the executable file. Run it to install.

Then we are all set. But keep in mind we have 30-day free trial. After which I recommend you pay for the licence which is just about $150 for the whole year.

The user interface is shown below:

Studio 3T User Interface

Studio 3T User Interface

4. Get the MongoDB Compass

I also recommend you download and install MongoDB Compass. This is another GUI tool used for managing MongoDB databases. With MongoDB Compass, you can perform CRUD operations(Create, Read, Update and Delete) in with your data. You will also be able to view and optimize your queries.

Download MongoDB Compass here

MongoDB Compass GUI

MongoDB Compass GUI

Next Steps

As for how to use the GUI to create and manage databases, I recommend you watch the detailed video lessons. In the next class, we would the create a project in Spring Boot that would store data in MongoDB.

Watch the Video below