MongoDB on Debian

[**MongoDB**]( is a cross-platform document-oriented database system. MongoDB is classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favour of JSON-like documents with dynamic schemas (MongoDB calls the format BSON). BSON makes the integration of data in certain type of applications easier and faster. MongoDB has been adopted as a backend database software by a number of major websites and services, including [New York Times](, [eBay](, [Foursquare](, among others. MongoDB is the most popular NoSQL database system. Here is an easy guide to install MongoDB on your [Debian]( Server.


  • Ad hoc queries

MongoDB supports search by field, range queries, regular expression searches. Queries can return specific fields of documents and also include user-defined JavaScript functions.

  • Indexing

Any field in a MongoDB document can be indexed (indexes in MongoDB are conceptually similar to those in RDBMSs). Secondary indices are also available.

  • Replication

MongoDB provides high availability and increased throughput with replica sets. A replica set consists of two or more copies of the data. Each replica may act in the role of primary or secondary replica at any time. The primary replica performs all writes and reads by default. Secondary replicas maintain a copy of the data on the primary using built-in replication. When a primary replica fails, the replica set automatically conducts an election process to determine which secondary should become the primary. Secondaries can also perform read operations, but the data is eventually consistent by default.

  • File storage

MongoDB can be used as a file system, taking advantage of load balancing and data replication features over multiple machines for storing files.

  • Server-side JavaScript execution

JavaScript can be used in queries, aggregation functions (such as MapReduce), and sent directly to the database to be executed.

  • Capped collections

MongoDB supports fixed-size collections called capped collections. This type of collection maintains insertion order and, once the specified size has been reached, behaves like a circular queue.

  • These are some of the features of MongoDB. MongoDB offers more features.


Adding MongoDB PGP key.

sudo apt-key adv –keyserver –recv 7F0CEB10

Add MongoDB repository to ‘/etc/apt/sources.list.d’ folder.

echo ‘deb dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

update local package database.

sudo apt-get update

Installing latest version of MongoDB available for Debian.

sudo apt-get install mongodb-org

Access MongoDB shell.


We now have MongoDB installed on your Debian Server. If you have any problem feel free to leave a comment below.