Medium Feed


Tuesday, January 19, 2016

How to setup MongoDB environment

Recently I had setup MongoDB in my machine, here sharing the learning of end to end steps involved to setup Mongo DB and confirm the installation.

Steps to install MongoDB

Ø  Go to and grab installation file, make sure you selected correct development environment
Ø  Start run the installation file and follow the prompts
Ø  Installation path prompt click “Custom” and change the installation path to “C:\MongoDB” ( just for easy reference purpose)
Ø  Add the installation path (C:\MongoDB) to environment variables
Steps to add in environment variables:
Windows 7:
                My Computer > Properties > Change settings > Advanced > Environment variables
              > Click Path > Edit > at the end of existing entries type semicolon “;” and add installation path “C:\MongoDB” next to that. > Click Ok > Ok.

Ø  Once installation finished open the folder “C:\MongoDB” and create 2 sub folders inside it
two subfolders:  “conf”, “log”
Ø  Open a text editor and add the following code :
# mongodb.conf
# point mongodb to the data directory
dbpath=C: \data\db
# tell it where to log messages
# only run on localhost
bind_ip =                                                            
port = 27017
rest = true
Ø  Save the file with name “Mongodb.conf” and save it inside the folder “C:\mongodb\conf”
Ø  Go to “C” drive and create a new folder “data”  (i.e C:\data )
Ø  Go to created folder and create a subfolder with name “db”. So the path will be “C:\data\db”

You are done, MongoDB setup is done.
Here’s the steps to confirm the setup:
Ø  Open command prompt
Ø  Navigate to “C:\MongoDB\Bin” folder in command prompt
Ø  Type “Mongod” and enter
Ø  You should able to see messages like “Waiting for connections on port 27017”
Ø  Open a new command prompt ( don’t close exiting command prompt)
Ø  Navigate to “C:\MongoDB\Bin” folder in command prompt
Ø  Type “Mongo” and enter
Ø  You will be getting a message “MongoDB shell version and connecting to “test” db”
Ø  Also if you see in another opened command prompt, the message will be changed to “Connection accepted from “”…etc”

That’s it , your setup and confirmation done. Now you can start interacting with db either through app or via cmd prompt.

No comments:

Post a Comment