This version has reached end of life on October 2016. Learn more about upgrading your version of MongoDB.

Install MongoDB Enterprise on Debian


Use this tutorial to install MongoDB Enterprise from .deb packages on Debian 7.


MongoDB provides packages of the officially supported MongoDB Enterprise builds in it’s own repository. This repository provides the MongoDB Enterprise distribution in the following packages:

Control Scripts

The mongodb-enterprise package includes various control scripts, including the init script /etc/rc.d/init.d/mongod.

The package configures MongoDB using the /etc/mongod.conf file in conjunction with the control scripts. See the Configuration File reference for documentation of settings available in the configuration file.

As of version 2.6.12, there are no control scripts for mongos. The mongos process is used only in sharding. You can use the mongod init script to derive your own mongos control script.


Changed in version 2.6: The package structure and names have changed as of version 2.6. For instructions on installation of an older release, please refer to the documentation for the appropriate version.

Use the provided distribution packages as described in this page if possible. These packages will automatically install all of MongoDB’s dependencies, and are the recommended installation method.

To manually install all dependencies, run the following command:

sudo apt-get install libgssapi-krb5-2 libsasl2-2 libssl1.0.0 libstdc++6 snmp

Install MongoDB Enterprise


Import the public key used by the package management system.

Issue the following command to add the MongoDB public GPG Key to the system key ring.

sudo apt-key adv --keyserver --recv 9ECBEC467F0CEB10

Create a /etc/apt/sources.list.d/mongodb-enterprise.list file for MongoDB.

Create the list file using the following command:

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

If you’d like to install MongoDB Enterprise packages from a particular release series, such as 2.6, you can specify the release series in the repository configuration. For example, to restrict your system to the 2.6 release series, add the following repository:

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

Reload local package database.

Issue the following command to reload the local package database:

sudo apt-get update

Install the MongoDB Enterprise packages.

When you install the packages, you choose whether to install the current release or a previous one. This step provides instructions for both.

To install the latest stable version of MongoDB Enterprise, issue the following command:

sudo apt-get install mongodb-enterprise

To install a specific release of MongoDB Enterprise, specify each component package individually and append the version number to the package name, as in the following example that installs the 2.6.9 release of MongoDB Enterprise:

sudo apt-get install mongodb-enterprise=2.6.9 mongodb-enterprise-server=2.6.9 mongodb-enterprise-shell=2.6.9 mongodb-enterprise-mongos=2.6.9 mongodb-enterprise-tools=2.6.9

You can specify any available version of MongoDB Enterprise. However apt-get will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, pin the package. To pin the version of MongoDB Enterprise at the currently installed version, issue the following command sequence:

echo "mongodb-enterprise hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-server hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-shell hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-mongos hold" | sudo dpkg --set-selections
echo "mongodb-enterprise-tools hold" | sudo dpkg --set-selections

Run MongoDB Enterprise

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodb by default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.

If you change the user that runs the MongoDB process, you must modify the access control rights to the /var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.


Start MongoDB.

Issue the following command to start mongod:

sudo service mongod start

Verify that MongoDB has started successfully

Verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading

[initandlisten] waiting for connections on port <port>

where <port> is the port configured in /etc/mongod.conf, 27017 by default.


Stop MongoDB.

As needed, you can stop the mongod process by issuing the following command:

sudo service mongod stop

Restart MongoDB.

Issue the following command to restart mongod:

sudo service mongod restart

Begin using MongoDB.

To begin using MongoDB, see Getting Started with MongoDB. Also consider the Production Notes document before deploying MongoDB in a production environment.

Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.

Uninstall MongoDB

To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.


This process will completely remove MongoDB, its configuration, and all databases. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.


Stop MongoDB.

Stop the mongod process by issuing the following command:

sudo service mongod stop

Remove Packages.

Remove any MongoDB packages that you had previously installed.

sudo apt-get purge mongodb-enterprise*

Remove Data Directories.

Remove MongoDB databases and log files.

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb