MongoDB is a very powerful resource and fast NoSQL database. As for the repositories on Debian, they update very slowly and often contain outdated versions of packages. This tutorial will aim to give an example of how to install the latest version of MongoDB from the official MongoDB repository.
Add MongoDB Public Key
The command below adds the MongoDB public GPG key to the set of all other system keys. Debian’s package management tools need this key to ensure consistency and authenticity of packages.
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
Add MongoDB Repository
First, you need to create a mongodb.list file to add the MongoDB repository to your system. This command, which is described below, will give you the opportunity to create the required file:
echo "deb http://repo.mongodb.org/apt/debian "$(lsb_release -sc)"/mongodb-org/3.0 main" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
Use the command below to get complete information about the latest packages in the repositories:
Install MongoDB packages
To install the latest stable version of MongoDB, use the following command, which is provided below:
apt-get install -y mongodb-org
mongodb-org is a “metapackage” that automatically installs four component packages:
After the installation isfinished, MongoDB will be started immediately. If you need to manually run the MongoDB server, then use the following command:
service mongodb start
To stop the mongodb process, use this command:
service mongodb stop
And to restart mongodb, use the following:
service mongodb 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.
Leave A Comment?