Install Setup and Start MongoDB on Windows

In this particular blog we will see How to setup or Install MongoDB in a Windows environment. Firstly we will discuss a very easy and quick setup to get started with mongoDB on windows and later on a simple test with a sample code pf creating a database and table in MongoDB.

It is not actually necessary to install MongoDB on windows as we do for a number of windows application, we just need to download MongoDB distribution, setting environment variable and a little configuration and everything w'll be up and running in few minutes.

Install, Setup MongoDB on windows quickly

Following are the steps to get MongoDB up and running on windows environment in minutes.

1)  Download appropriate MongoDB distribution depending upon your system configurations.(32-bit or 62-bit).
2)  Unzip the distribution somewhere in your local drive, say 'D:\mongo'. You will see a 'bin' folder containing some .exe files as shown in the figure below.

3)  Go to your system's 'Environment Variables' and set path for MongoDB, as 'D:\mongo\mongodb-win32-i386-2.4.5\bin'.

4)  Go to your C drive and create a folder to store your database files, as 'C:\data\db', make sure you have created this folder as said, we can change this with a little configuration but for now create it as said. MongoDB w'll look for a 'C:\data\db' bydefault.

Start MongoDB from command line.

Following are the steps to check a MongoDB installation and setup in windows environment.

1) Open command prompt and type 'mongod', you will see a black screen telling some details about your MongoDB :

You may get a last line saying, 'connectiong to port ...', dont worry about it sometimes it may take upto 10-12 minutes to get connection. But there is an another way to get rid of it.

2)  Just open an saperate command prompt and type command 'mongo'. You will get a connection successfully to MongoDB as shown in the figure.

In the same time look at your previous command prompt instance and you will get it connected instantly, as shown in the figure below.

Congratulations ! You are just done with configuring MongoDB on your machine.

Testing MongoDB installation.

To test if you did the configurations right and everything is working fine do a simple DB and Table creation with a little data.

Note down we just used the db without creating it, this is MongoDB we dont need to create a DB or Table before using it or inserting data into it, at the time we insert data in a table it's created automatically if not exists. Command 'db.user.find()' is used to show data inside 'user' table.

Thats It ! we are done with getting MongoDB up in minutes. 

In this particular blog we came across ?Install Setup and Start MongoDB on Windows'. In upcoming blogs we will see more about 'MongoDB', Java and other opensource technologies.