MongoDB – Installation and basic commands

MongoDB is a document-orientated database, a NoSQL database with a JSON-like documents and dynamic schema:

  • Tables are collections
  • Rows are documents
  • No schema

The advantages of using documents:

  • Documents (objects) correspond to native data types in many programming languages.
  • Embedded documents and arrays reduce need for expensive joins.
  • Ability to perform dynamic queries on documents using document-based query language.
  • Conversion of objects to database objects is not needed
  • High performance – uses internal memory to shore working sets of quick data access.

Advantages of MongoDB vs RDBMS

  • Schema less – the document is flexible compared to “table” structure including nullable fields from RDBMS. One collection can hold even different different documents. Number of fields, content and size of the document can be differ from one document to another.
  • No complex joins – as data is usually stored with the same document. We’re going to discuss about embedding related data in document and how MongoDB is dealing with the lack of relations.
  • Ease of scale-out – MongoDB is easy to scale.
  • Conversion / mapping of application objects to database objects not needed. See
  • Document Oriented Storage: Data is stored in the form of JSON style documents. Everybody is talking JSON there days: client, server and database.
  • Atomic – in-place updates: $inc, $set, $push, $pop, $rename, $bit. No need to deal with the complexity of transactions.

Where should use MongoDB?

  • Big Data
  • Content Management and Delivery
  • Mobile and Social Infrastructure
  • User Data Management
  • Data Hub


MongoDB is a cross-platform so major OS are covered together with the option to install manually or via setup procedure (msi, apt-get, homebrew).

Below we’re going to add the steps to manually install mongoDB on Windows platform. You can find the latest stable release here.

For Debian/Ubuntu installation, please use this link.

For the installation of mongodb I recommend to use a custom folder (eg.d:\mongodb) Also is recommended to open cmd.exe as admin and then create data\db and log folders.

You could simplity and add some details into mongo.config to adjust the config of mongod service:

For the manually binary installation it’s better to start the mongod as a windows service:

Mongo Shell

Let’s start the shell by using mongo.exe.
is the mongoDB server.

Below some basic mongodb shell commands:

This is the first article on a series of mongoDB related ones.

Additional links: