In this page, we will begin with Document based Database called Mongodb which is quite popular among the developers worldwide.
MongoDB is a document based NoSQL DB.
It has become quite popular over the recent years and many big clients and organizations are the major supporters of this database. It was initially launched in 2009 and is developed and distributed by 10gen organization.
Its open source and is freely available for the developers to explore and learn the database.
MongoDb Setup and installation
MongoDb comes in 32/64 bit flavors for different OS platforms. You can get the installation from
It is always preferred to install 64 bit flavour for better performance.
MongoDb Installation on Windows environment
Here are the steps of installtion Mongodb in Windows.
- Create a folder in C drive with mongo name.
- Click on Mongodb installer for windows.
- Continue to click next until you get the below screen
MongoDB windows installer
- Select Custom and provide the path for mongo folder created in step 1.
MongoDB windows installation location
With this mongodb is installed in your machine.
My installation path is C:\mongo\bin
MongoDB windows installer files
Testing for bug
Next we need to do some certain configuration for mongodb. There is a small bug in the Mongodb windows
installer which some of you might face while trying to run the service.
In order to check for the bug open the command console and give the command as below:-
MongoDB windows installer bug
When you see this issue then you have to do certain configuration inorder to run mongodb.
This configuration will try to resolve the bug and also set the system path to
automatically pick up the command to run mongodb.
Configuring mongodb in Windows
Running the MongoDb service
- Create another folder called data inside installation folder.
- Inside bin folder create a startmong.bat file and open it with notepad application
- Copy the below command inside startmongo.bat file
mongod --dbpath C:\mongo\data
- Now close the startmongo.bat file
- Open environment or system variables through properties
Windows environment variable
- Go to Path and edit it. Add the path to bin folder of mongodb installation.
Create Windows environment variable for mongodb
- Click ok and close all the windows. With this we are done with configuration of the Mongodb on windows machine.
Mongodb has two components namely service and shell prompt to connect to the database.
After the configuration has been done it eliminates the need to provide a path to the bin folder (in the command prompt every time you want to run the MongoDB).
In order to run the MongoDB service open the command prompt and provide the command startmongo.
Once you execute startmongo you will get screen as below :-
Mongodb service startmongo
The bug will be visible on the screen but it won't stop the service and service will run uninterrupted.
Opening shell prompt
Open another command window and give command mongo and you will get screen as below :-
Now mongodb is fully installed and running successfully on windows machine.
MongoDb Installation on Ubuntu
MongoDb Installation on Ubuntu is very easy and doesn't have the complexity of windows machine.
If you don't want to fall into too much complexity and want simple installation then follow the steps as mentioned below :-
- Run the below commands from terminal of Ubuntu
$ sudo apt-get update
$ sudo apt-get install mongodb install -y mongodb-org
- Start the mongod service by executing the commands as below :-
$ sudo service mongod start
- Open another terminal window and execute command :-
The above command would open the shell prompt which will connect to mongodb.
Your MongoDB installation is complete and ready to be used.