Casbay Knowledge Base

Search our articles or browse by category below

Installing MongoDB for Linux Based VPS in 3 Simple Steps

Last modified: September 30, 2022
Estimated reading time: 1 min

MongoDB is one of the most well-known NoSQL database managers. MongoDB is used for saving documents instead of data record such as SQL and applications that save data in formatted documents relies on it. MongoDB is also popular in environments that require a lot of scalabilities. You can quickly conduct replication procedures using MongoDB, allowing data scalability. MongoDB can be used by any application that needs to store semi-structured data.

In this article, we will be guiding you on how to install MongoDB in your Linux based VPS. The Linux distribution used in this tutorial is Ubuntu version 18.04.

Step 1: Connect Server With SSH

First and foremost, connect to the server using SSH. Make sure you have the sudo privilege within the server as well.

ssh <user_name>@<server_name>

Replace “<user_name>” and “<server_name>” with your own username and the name of the server respectively.

Step 2: Add MongoDB repository

To avoid compromising downloaded packages, add the PGP key from the MongoDB repository.

sudo apt-key adv --keyserver hkp:// --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

After adding the PGP key, run the following command to install the MongoDB repository.

echo "deb [ arch=amd64 ] bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Next, update all the repositories using the following command.

sudo apt update

Step 3: Installation

To install MongoDB into your VPS, run the following commands.

sudo apt-get install -y mongodb
sudo apt install mongodb-org

After finishing installing MongoDB, you may start it using the start command as followed.

sudo systemctl start mongodb

To start MongoDB on every system boot, use the following command.

sudo systemctl enable mongodb

Finally, to check the status of MongoDB, run the following command.

sudo systemctl status mongodb

You have completed installing MongoDB into your system. Retrace the previous steps if there are any issues with the installation.

Was this article helpful?
Dislike 0
Previous: Redis Installation Guide on Linux Based VPS in 3 Simple Steps
Next: Maven Installation Guide on Linux Based VPS in 4 Simple Steps