Beginners guide to installing and setting up MongoDB and GUI for MongoDB in Windows Machine

September 26, 2019

This is a step by step tutorial for installing MongoDB and setting up a GUI for MongoDB on Windows OS

 

Step – 1

Check whether MongoDB is already installed in the system

To check whether MongoDB is already installed in the system, and the PATH variable is configured, use the following command. This will output the version of MongoDB .

The following command will output the Mongo shell version

If installed and configured, the output will be something like

db version v3.4.14 –          mongod -version

MongoDB shell version v3.4.14 –           mongo -version

If not, the output will be like

 

 

Step – 2

Download and install  MongoDB and the mongo shell on Windows machine

Go to the MongoDB official site and download the setup file for Mongo and install it on the machine. The default installation folder will be inside program files in your C drive

You can customize your installation and also choose whether to install or not install the MongoDB Compass which is an intuitive GUI by MongoDB Inc.

Navigating to the bin folder and running the commands in Step 1 will give you the versions of currently installed Mongo . Adding the path of  bin folder to the path environment variable makes the commands to be run globally

Get  the setup file  –    https://www.mongodb.com/download-center/community

 

 

Step – 3

Add path to the environment variable PATH

Search for environment variables in your windows search. In the environment variables set the path to the Mongo bin folder against PATH. If not exists create the variable. If exists add to the existing PATH by separating with a semicolon in the following way.

 

 

Step – 4

Running the commands in step-1 again to check the installation

Running the version check commands again will produce output like this

Shell version with mongo -version                       

 

 

DB version with mongod -version 

 

 

 

Step – 5

Starting  Mongo and  Mongo shell

running the above command will start MongoDB on the default port 27017. The command will give an output like the following

 

The default db path is c:\data\db. If the folder doesn’t exist, running mongod command will throw an error like

Either a  folder should be created as specified in the default path. To use a different path, run mongod with the option dbpath

 

 

The Mongo shell is started using the following command

Starting Shell will provide an output in the console like the following

Running the command

will show the currently selected DB like this. By default, the DB name will be test initially

To switch to  another DB, the following command is used

 

Step 6 

GUI tools for MongoDB

The default DB GUI provided by the creators of MongoDB goes by the name MongoDB compass. This can be downloaded from MongoDB Inc website https://www.mongodb.com/download-center/compass.The interface of MongoDB compass will look like this. The default configuration to connect to the DB locally will be provided in the interface.

Another popularly used DB GUI is Robo 3T. The GUI can be downloaded from the link https://robomongo.org/download.The interface of Robo 3T

 

These GUI tools can be used to do CRUD operations on MongoDB.This article is aimed at just installing MongoDB and GUI. For more articles on how to use the  DB, subscribe to Truetocode.com.

All the best with Mongo…3

 

No Comments

Leave a Reply

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