MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++.MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection(Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collection exists within a single database.) and document(A document is a set of key-value pairs).

Example :

Following example shows the document structure of a blog site, which is simply a comma separated key value pair.

   _id: ObjectId(7df78ad8902c)
   title: 'MongoDB Overview', 
   description: 'MongoDB is no sql database',
   by: 'tutorials point',
   url: '',
   tags: ['mongodb', 'database', 'NoSQL'],
   likes: 100, 
   comments: [  
         message: 'My first comment',
         dateCreated: new Date(2011,1,20,2,15),
         like: 0 
         message: 'My second comments',
         dateCreated: new Date(2011,1,25,7,45),
         like: 5

Note : _id is a 12 bytes hexadecimal number which assures the uniqueness of every document. You can provide _id while inserting the document. If you don’t provide then MongoDB provides a unique id for every document.

Install MongoDB On Windows

  • Download the latest release of MongoDB from

  • Now extract your downloaded file to c:\ drive or any other location.

  • Next, open the command prompt and run the following command

          C:\>move mongodb-win64-* mongodb
             1 dir(s) moved.
  • Create this folder using the Command Prompt()MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db. Execute the following command sequence.

                  C:\>md data
                  C:\md data\db

In the command prompt, navigate to the bin directory present in the MongoDB installation folder. Suppose my installation folder is D:\set up\mongodb

             D:\>cd "set up"
             D:\set up>cd mongodb
             D:\set up\mongodb>cd bin
             D:\set up\mongodb\bin>mongod.exe --dbpath "d:\set up\mongodb\data" 
  • Now to run the MongoDB, you need to open another command prompt and issue the following command.
          D:\set up\mongodb\bin>mongo.exe
            MongoDB shell version: 2.4.6
            connecting to: test
            > { a: 1 } )
            { "_id" : ObjectId(5879b0f65a56a454), "a" : 1 }
  • Next time when you run MongoDB, you need to issue only commands.
          D:\set up\mongodb\bin>mongod.exe --dbpath "d:\set up\mongodb\data" 
            D:\set up\mongodb\bin>mongo.exe

Leave a Reply

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