Installing MongoDB for Ubuntu: A Beginner-Friendly Tutorial


A well-liked NoSQL database called MongoDB is renowned for its adaptability, scalability, and capacity to manage sizable amounts of unstructured data. Installing MongoDB on your Ubuntu machine is a straightforward process that enables you to leverage the power of this popular NoSQL database for your applications. Whether you are a developer, system administrator, or a curious beginner.

In this tutorial, we'll walk you through the steps to Install MongoDB on Ubuntu, so you can start building powerful applications that leverage the power of MongoDB.


Before we get started with the installation, there are a few prerequisites you'll need to meet:

  • A Ubuntu machine with root or sudo access
  • A terminal or command-line interface

Step 1: Import the MongoDB GPG Key

The first step in installing MongoDB on Ubuntu is to import the MongoDB GPG key. This key is used to verify the authenticity of the MongoDB packages you'll be installing.

To import the key, open a terminal and run the following command:

sudo apt-key adv --keyserver hkp:// --recv 4B7C549A058F8B6B

Step 2: Add the MongoDB Repository to Ubuntu

Next, you'll need to add the MongoDB repository to Ubuntu. This repository contains the MongoDB packages you'll be installing.

Run the following command in your terminal to add the repository:

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

This command adds the MongoDB repository to your list of software sources.

Step 3: Install MongoDB on Ubuntu

With the MongoDB repository added to Ubuntu, you're now ready to install MongoDB. To do this, enter the command below into your terminal:

sudo apt-get updatesudo apt-get install mongodb-org

This command updates your package list and installs the MongoDB packages.

Step 4: Start the MongoDB Service

Once MongoDB is installed, you'll need to start the MongoDB service. To do this, enter the command below into your terminal:

sudo systemctl start mongod

This command starts the MongoDB service on your Ubuntu machine.

Step 5: Verify the MongoDB Installation

To verify that MongoDB is installed and running correctly, you can use the mongo shell. The mongo shell is a command-line interface for interacting with MongoDB.

To start the mongo shell, open a new terminal window and run the following command:


This command starts the mongo shell and connects to the MongoDB instance running on your Ubuntu machine.

Once you're connected to the mongo shell, you can run the following command to verify that MongoDB is running correctly:


This command returns the version of MongoDB that is installed on your Ubuntu machine.

Installing MongoDB in Ubuntu has several benefits, including: 

Easy Installation: Ubuntu's official package repositories include a stable version of MongoDB, which makes it easy to install MongoDB on Ubuntu. It only takes a few simple steps to complete the installation procedure.

Flexibility: MongoDB is a document-oriented database that stores data in a more flexible manner than a traditional relational database. It is a strong fit for unstructured or partially organized data and works well with object-oriented architectures.

Scalability: MongoDB is known for its ability to handle large volumes of unstructured data. It is a highly scalable database that can be used for a wide range of applications, from small-scale projects to large-scale enterprise solutions. 

Performance: MongoDB is designed to be fast and efficient, with features such as automatic sharding and indexing that help to improve performance. 

Community Support: MongoDB has a large and active community of developers who contribute to its development and provide support to users. This community provides a wealth of resources, including documentation, tutorials, and forums, that can help users get started with MongoDB and troubleshoot any issues they encounter.


In addition to the benefits of installing MongoDB in Ubuntu, our product AppInvento is a powerful backend builder that can help users build and deploy scalable and efficient applications quickly and easily. AppInvento provides a user-friendly interface that allows users to create and manage their backend infrastructure without the need for extensive coding or technical expertise.

With AppInvento, users can easily create custom APIs, manage databases, and handle user authentication and authorization. AppInvento also provides a range of pre-built templates and integrations that make it easy to get started with building applications quickly.

One of the key benefits of using AppInvento is its scalability. AppInvento allows users to easily scale their backend infrastructure as their application grows, ensuring that their application can handle increased traffic and data volumes without compromising performance.

Overall, AppInvento is a powerful tool that can help users build and deploy scalable and efficient applications quickly and easily. By combining the power of MongoDB with the ease of use of AppInvento, users can build powerful applications that can handle a wide range of use cases and scenarios.


MongoDB Installation on Ubuntu is a simple process that only requires a few simple steps to finish. By following this tutorial, you'll be able to install MongoDB on your Ubuntu machine and start building powerful applications that leverage the flexibility and scalability of MongoDB. Remember to keep your MongoDB installation up-to-date by regularly updating your packages and monitoring your system for security vulnerabilities.