Install MongoDB – A NoSQL Database

There are various NoSQL databases such as : MongoDB, Rethink DB, CouchDB etc. You know what are NoSQL databases and what are SQL databases. So in this we will learn about MongoDB that is a NoSQL Database .


MongoDB Installation Steps

1) Go to MongoDB website and click on the TAB ” Community Server “.
2) Select the version as per you system configuration from ” Version ” dropdown.
3) Click on “Download” button.

mongo website

Note -> In this tutorial the windows files are in C://, so all the examples are taking considering C:// as window folder

4) After installing the .exe file, Make a new folder named as data.
5) Create a new folder named as “db“inside Folder “data“.


Run MongoDb Server

There are two ways to run the mongodb server.

Method 1 : 

1) Open command Prompt.
2) Then type this command ” cd C://Program Files/MongoDB/Server/3.0/bin in command prompt and press Enter.
3) Type “ mongod ” and press enter and mongodb server starts.

Method 2 :

1) Select the directory path where the mongod is present that is ” C://Program Files/MongoDB/Server/3.0/bin ” copy  it.
2) Right click on My Computer, then Properties.
3) Click on Advanced system Settings and click on environment variables.
4) Scroll down to the path variable.
5) Click on edit.
6) Go to the very end. Add a semicolon.
7) And then paste the directory path.
8) Click on OK. And then Close.
9) Open command prompt
10) Type “ mongod ” and press enter and mongodb server starts.

After running mongod in the command prompt you would see like this:

mongod

Now MongoDB server is running , leave that command prompt window open. If we close that Window then Mongodb server will get close.


How to Run Mondodb

1) Open a new command prompt window and type ” mongo ” and press enter.

mongo

Output : 

Note : See the blue link, one connection is now open, it shows that one connection request has been made with the mongodb server.

2) Type “ db ”  in command prompt and press enter.

db

If it says ” test ” it means you have successfully install the mongodb in your system. So test is the database that mongodb provides by default and we are currently using that.

 

db-test


Using the MongoDB GUI for Production

We do not use command prompt for Mongodb execution. We need to install MongoDB GUI for windows named as ROBO3T.

Steps to download ROBO3T

1) Go to ROBO3T and download it from there.

Output 

robo3t

2) Open ROBO3T and click on the menu bar and then click on file.
3) Click on connect.

(simply press CTRL +N). A new popup opens.

connection

4) Click on Create. Another popup window will open.
5) In Pop Window add the below information.

a) Name = “any Name ” or leave as default “New Connection“.
b) Address should be localhost.
c) Port as  27017 (write if it is not already there) as in below screen shot.

6) Click on “Save” button.

connection request

New Connection as address localhost:27017, in the mongodb connections window will appear.

7) Click on connect.saving the connection

8) on the left hand side you will get some dbs such as config in the left hand side (see in the below figure).

done connection

This way we have installed the Mongodb server in our machine. If you have any queries regarding installation of MongoDB, drop a comment below.

Leave a Comment

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