MongoDB Setup

There are a total of eight steps that we will follow to install MongoDB. These steps will start with how to download MongoDB. Afterwards, we will look at how to install MongoDB.

Before diving into our tutorial, let’s have a look at the topics that we are going to cover in this tutorial:

Steps to Follow to Install MongoDB

Step 1:

  • Go to the link:

https://www.mongodb.com/download-center/community

  • Download MongoDB Community Server. You will see the installation of the 64-bit version for Windows

Download MongoDB - Intellipaat

Step 2:

  • After downloading the setup, open the MSI file
  • Click on Next on the setup screen

Welcome page MongoDB installation - Intellipaat

Step 3:

  • Accept the End-User License Agreement
  • Click on Next

Terms and condition MongoDB - Intellipaat

Step 4:

  • On the next screen, click on the Complete button to install MongoDB components. If you choose the custom option, then you can install selective components and you can change the location of the installation if needed

choose setup - intellipaat

Have you got more queries? Come to our Community and get them clarified today!

Step 5:

  • Now, select Run service as Network Service user
  • Copy the Data Directory location. You will need this in a later step
  • Click on Next

Service configuration MongoDB

Step 6:

  • Click on the Install button to start installing MongoDB

Ready to install MongoDB - Intellipaat

Step 7:

  • At this point, the installation process starts. Once it is completed, click on Next

Process of downloading MongoDB - Intellipaat

Step 8:

  • Finally, click on Finish to complete installation

Finish installation - Intellipaat

To verify whether the installation has been completed successfully, you have to open a Command Prompt and write mongo, and then you have to check MongoDB versions. If they are shown correctly, it means that MongoDB is installed successfully.

Version checking MongoDB - Intellipaat

Go for this in-depth job-oriented MongoDB Training Course now!

‘Hello World’ Code in MongoDB

In our code, we are just declaring a simple JavaScript variable to store a string called ‘Hello World’, and for printing the value on the screen we are using the print Json method.Hello World in MongoDB - Intellipaat

Installing RoboMongo for MongoDB

To write MongoDB commands, we need a tool; therefore, we use RoboMongo. We can also use MongoDB Compass for that, but in this tutorial, we have used RoboMongo.
RoboMongo is free and open-source software that supports all three operating systems: Windows, Linux, and Mac OS. Now, it depends on you which tool you want to use.

Steps to Download and Install RoboMongo

Step 1:

  • Go to the link: https://robomongo.org/download
  • Click on the Download Robo 3T button and download the setup depending upon your PC’s architecture. Here, it is the 64-bit version

RoboMongo Download - Intellipaat

Step 2:

  • In the new window, select your operating system
  • Once you select the OS, click on the version (i.e., 64-bit version)

Choosing the exe file RoboMongo - Intellipaat

Step 3:

  • You have downloaded the setup. Now, click on the .exe file
  • Click on Next

Welcome Page RoboMongo - Intellipaat

Step 4:

  • In the new window, click on I Agree for accepting the license agreement’s terms and conditions

License Agreement - Intellipaat

Step 5:

  • Click on Install and the installation process starts

Installation Page - Intellipaat

Step 6:

  • In the new window, you need to create your new connection, but before that go to the Command Prompt and write mongod to start MongoDB

Mongod to start server - Intellipaat

Step 7:

  • Later on, press on Create
  • In the pop-up window, name your connection
  • Click on Save and then on Connect

Connecting to the database - intellipaat

creating the database - Intellipaat

Check out the top MongoDB Interview Questions to learn what is expected from MongoDB professionals!

Step 8:

  • Once the connection is created, right-click on it and open the new shell. Now, you are ready to write your database query

opening the robomongo editor - intellipaat

So far, we have learned the steps to download and install MongoDB. Now, we will move ahead with the most important topics, i.e., various queries in MongoDB and how to write and execute them.

MongoDB installation on Linux

The installation packages of 64 and 32 bits are available on the web for Linux. In order to install the tool, you need to download a suitable package.

Step 1:

  • Download the package: Download the MongoDB packages from the following link: http://www.mongodb.org/downloads

download the package

Step 2:

  • Unzip the folder: Unzip the downloaded folder at the location where you would like to install the tool

Step 3:

  • Create a data directory: Create a data directory manually in the root as the data is stored in this directory only

Create a Data Directory

Step 4:

  • Run MongoDB server: Run the MongoDB server on the command prompt for which you need to execute the mongod.exe file from the bin folder inside the MongoDB folder

Step 5:

  • Start Administrative Shell: Specify the bin directory location of the MongoDB package and run mongo.exe file. The administrative shell is a JavaScript shell and the moment you install MongoDB, it will connect you to the test document.

Concluding this tutorial, so far, we have learned how to download and install MongoDB, and then we saw how to download Robo 3T and install it for writing the MongoDB commands. I hope this tutorial has helped you clear all the doubts that arise when you start learning MongoDB so that you can choose the right career path.

Recommended Videos

Leave a Reply

Your email address will not be published. Required fields are marked *