Home → Articles → How to Install MongoDB Database Server on Ubuntu 26.04

How to Install MongoDB Database Server on Ubuntu 26.04

09 May, 2026

Introduction

MongoDB is a popular open-source NoSQL database that stores data in flexible, JSON-like documents rather than traditional table-based structures. Unlike relational databases that require predefined schemas, MongoDB allows you to store data with varying fields and structures within the same collection. This document-oriented approach handles unstructured or semi-structured data efficiently, making MongoDB a preferred choice for modern applications that require rapid iteration and scalability. Many development teams use MongoDB for content management systems, real-time analytics, catalogs, and mobile applications where data models evolve frequently.

This tutorial teaches you how to install and configure MongoDB on Ubuntu 26.04.

Prerequisites

Before you start:

Understand MongoDB Terminology Compared to SQL Databases

MongoDB uses different terminology than traditional SQL databases. Understanding these differences helps you transition between database systems. The table below maps common SQL concepts to their MongoDB equivalents.

SQL Concept MongoDB Concept Description
Database Database Both systems use databases to contain related data
Table Collection A group of documents in MongoDB, equivalent to a table in SQL
Row Document A single data record, stored as a BSON document in MongoDB
Column Field A key for a value within document in MongoDB
Column Value Key Value The actual value of a column (in SQL) or a actual value of a key (in MongoDB)
Primary Key _id field MongoDB automatically creates a unique _id field for each document
JOIN Embedded documents or $lookup MongoDB supports embedding related data directly or using aggregation lookups
GROUP BY Aggregation pipeline MongoDB uses aggregation stages like $group for data grouping

Install MongoDB

MongoDB provides official packages for Ubuntu. To install the database server, follow these steps.

Manage MongoDB Service

MongoDB runs as a system service on Ubuntu under the name mongod. You can manage this service using specific commands to start, stop, restart, and check the MongoDB status. These commands ensure your database server runs correctly and simplify maintenance tasks.

Enable MongoDB to Start on Boot

console
$ sudo systemctl enable mongod

Output:

Synchronizing state of mongod.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable mongod

Check MongoDB Status

console
$ sudo systemctl status mongod

Output:

● mongod.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongod.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: https://docs.mongodb.org/manual

Press Ctrl + C to return to the shell prompt.

Start MongoDB Service

console
$ sudo systemctl start mongod

Check MongoDB Status

console
$ sudo systemctl status mongod

Output:

● mongod.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; preset: disabled)
     Active: active (running) since Tue 2026-04-30 08:15:23 UTC; 45s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 2456 (mongod)
     Memory: 198.2M
        CPU: 3.482s
     CGroup: /system.slice/mongod.service
             └─2456 /usr/bin/mongod --config /etc/mongod.conf

Stop MongoDB Service

console
$ sudo systemctl stop mongod

Restart MongoDB Service

console
$ sudo systemctl restart mongod

Secure MongoDB with Authentication

MongoDB does not enable authentication by default. To protect your database server, you create an administrative user and enable access control.

Test the MongoDB Database Server

In this section, you'll test MongoDB by logging in with the administrative user. Then, you'll create a sample database and collection, insert documents, and query the collection to verify the database works correctly.

Your MongoDB database server is working as expected.

Conclusion

In this guide, you have installed MongoDB on Ubuntu 26.04 using the official repository, secured the server with authentication, and tested the installation by creating a database with collections and documents. Now that you have MongoDB running, consider integrating the database with a programming language like Python using pymongo, with Node.js using the mongodb package, or with Java using the MongoDB Java Driver to build modern data-driven applications.