Install MongoDB on Linux Ubuntu: Step-by-Step Guide

Install MongoDB on Linux Ubuntu

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

MongoDB is a common NoSQL database known for its flexibility, scalability, and high performance. MongoDB stores data in JSON-like documents and is not a traditional relational database. It is best suited for unstructured and semi-structured data. In recent years, thousands of developers and big companies started using MongoDB because of its high efficiency in handling large-scale applications. So, the time has arrived to install MongoDB on Linux Ubuntu.

Installing MongoDB on Ubuntu guarantees compatibility with cloud platforms, containers, and contemporary web applications. This guide has a step-by-step process that you can execute, whether you want to install a local development environment or deploy it as a production database for Ubuntu.

At the end, you will have a fully working MongoDB running on your Ubuntu system, ready for your development or deployment.

What is MongoDB?

MongoDB is a high-performance, high availability, and easy-to-use NoSQL database. Document-oriented DB. This is extensively used in cloud applications, big data environments, and microservices.

Here are its features:

  • Ability to store unstructured or semi-structured data.
  • Provides built-in sharing capabilities.
  • Offers optimized read/write operations for real-time applications.
  • Also supports indexing, aggregation, and full-text search.

Install MongoDB on Linux Ubuntu

Now, let’s learn how to install MongoDB on Ubuntu:

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

Step 1: System Update

System update for compatibility before MongoDB installation:

sudo apt update && sudo apt upgrade -y

Step 2: Add the MongoDB GPG Key

You will need a GPG key to verify that the package you download is authentic from MongoDB. 

Step 3: Add MongoDB Repository

Next, add the official repository for MongoDB to your package sources:

echo "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list

Step 4: Install MongoDB on Ubuntu

Run the following command for MongoDB installation on Ubuntu:

sudo apt update sudo apt install -y mongodb-org

This command installs:

  • mongodb-org-server: MongoDB Database Server
  • mongodb-org-shell: MongoDB Shell (CLI)
  • mongodb-org-tools: Database backup and monitoring utilities

Step 5: Start & Enable MongoDB

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

Start the MongoDB service and enable it to run on boot:

sudo systemctl start mongod sudo systemctl enable mongod

To check if MongoDB is running:

sudo systemctl status mongod

Output:

 mongod.service - MongoDB Database Server Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: active (running) since ...

Step 6: Check MongoDB Installation

To verify the installation, open the MongoDB shell:

mongosh

Output:

MongoDB shell version v7.0.2 Connecting to: mongodb://127.0.0.1:27017 test>

Step 7: Enable Remote Access (Optional)

MongoDB is only accessible from the localhost by default. To enable external connections, modify:

sudo nano /etc/mongod.conf

Locate the bindIp setting and edit it:

net: bindIp: 0.0.0.0

Save the file, then restart MongoDB:

sudo systemctl restart mongod

How to Install MongoDB on Ubuntu 22.04

The installation process is the same for Ubuntu 22.04. The only requirement is to ensure the system is updated:

sudo apt update && sudo apt upgrade -y

Then, go through Steps 2-7 for a complete installation.

How CyberPanel Helps Manage MongoDB

CyberPanel

CyberPanel is a modern web hosting control panel that efficiently simplifies server management, including database administration. Although its primary support is for MySQL, it can work in cloud and Docker-based deployments with MongoDB.

The Role of CyberPanel for MongoDB

  • Automation of database backups
  • Provides improved security through firewall and access control
  • Here are some ways that respective to easy server monitoring and performance optimization
  • Supports Docker and allows MongoDB Docker Containerized Deployments

FAQs to Install MongoDB on Linux Ubuntu

1. What is the current version of MongoDB for Ubuntu?

The current stable version is MongoDB 7.0 (for Ubuntu 20.04 and 22.04).

2. Is it possible to install MongoDB via Snap?

Yes, but not recommended as SnapPackages is/are not very configurable and might have some compatibility issues with certain systems.

3. How do I check what version of MongoDB I have?

To verify the installed version of MongoDB, run:

mongod –version

4. Is it possible to install MongoDB on Linux Ubuntu without an internet connection?

Yes, you can manually download MongoDB .deb packages from MongoDB’s official website and install them using:

sudo dpkg -i <package-name>

However, by doing this, you will have to manage the dependencies individually.

Conclusion: Install MongoDB on Linux Ubuntu for High-Volume Data Management

MongoDB is the leading NoSQL Database. Installing it on Ubuntu allows your data-driven projects to enjoy top-notch performance and stability.

So, with this step-by-step guide, you can easily install MongoDB on Linux Ubuntu and configure it on your system.

Start using MongoDB now for high-performance-based applications!

Hasib Iftikhar
I'm Hasib Iftikhar, a dedicated technical writer at CyberPanel, joining the team in July 2024. With three years of extensive experience in content writing, I specialize in copywriting, article writing, guest posting, affiliate content writing, and SEO. My expertise ensures that each piece of content I create is engaging, informative, and optimized for search engines, helping businesses enhance their online presence and reach their target audience effectively.
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!