Table of Contents
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Install Newer Versions of MongoDB on Debian 7

Last Updated: Fri, Mar 6, 2015
Databases Debian

MongoDB is a fast and powerful NoSQL database. However, Debian repositories update slowly and often contain very old versions of packages. This tutorial explains how to install latest version of MongoDB from the official MongoDB repository.

At the time of writing, 3.0 was the current version of MongoDB.

All commands below must be performed from the root user.

1. Add MongoDB public key

The following command adds the MongoDB public GPG Key to the system key ring:

apt-key adv --keyserver --recv 7F0CEB10

Debian package management tools need this key to ensure package consistency and authenticity.

2. Add MongoDB repository

Create a mongodb.list file to add the MongoDB repository to the system. The following command will create this file:

echo "deb "$(lsb_release -sc)"/mongodb-org/3.0 main" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list

3. Update packages

Use following command to get info about the lastest packages in repositories:

apt-get update

If you are familiar with Debian, you probably already know this command.

4. Install MongoDB packages

Now it's time to install MongoDB. To install the latest stable version of MongoDB, use the following command:

apt-get install -y mongodb-org

mongodb-org is a "metapackage" that will automatically install the four component packages:

  • mongodb-org-server
  • mongodb-org-mongos
  • mongodb-org-shell
  • mongodb-org-tools

If you need a specific version of MongoDB, you can use the following command to choose the version of each component:

apt-get install -y mongodb-org=3.0.0 mongodb-org-server=3.0.0 mongodb-org-shell=3.0.0 mongodb-org-mongos=3.0.0 mongodb-org-tools=3.0.0

In this example, I have selected version 3.0.0.

5. Start MongoDB

After the installation finishes, MongoDB is automatically started. If you need to manually run the MongoDB server, then use the following command:

service mongod start

To stop the mongod process, use this command:

service mongod stop

And to restart mongod, use the following:

service mongod restart

The MongoDB shell can be accessed by running the following command. This allows you to connect to the MongoDB server.


When the shell is launched, you will see output in this format:

MongoDB shell version: 3.0.0
connecting to: test

Now you can use MongoDB on your Debian server.

Want to contribute?

You could earn up to $300 by adding new articles