In this guide, you'll learn how to install the latest MongoDB Community Edition on Ubuntu 26.04 using the official MongoDB repository.
MongoDB is one of the most popular NoSQL databases used by developers around the world. Instead of storing data in tables like MySQL or PostgreSQL, MongoDB stores data as flexible JSON style documents. This makes it a great choice for modern web applications, APIs, analytics platforms, and microservices.
Prerequisites
- An Ubuntu 26.04 dedicated server
- A user with sudo privileges
- An active internet connection
Lets start learning how to install the latest MongoDB Community Edition on Ubuntu 26.04.
Step 1: Update Your System
Start by updating your package list.
sudo apt update
sudo apt upgrade -y
Step 2: Install Required Packages
Install the tools needed to add the MongoDB repository.
sudo apt install -y curl gnupg ca-certificates
Step 3: Import the MongoDB GPG Key
Download and install the official MongoDB signing key.
curl -fsSL https://pgp.mongodb.com/server-8.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg
Step 4: Add the MongoDB Repository
Since MongoDB has not yet released a repository for Ubuntu 26.04, add the Ubuntu 24.04 repository.
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
Step 5: Update the Package Index
Reload the package list.
sudo apt update
If everything is configured correctly, you should not see any repository errors.
Step 6: Install MongoDB
Install the latest MongoDB Community Edition.
sudo apt install -y mongodb-org
This installs the MongoDB server, shell, database tools, and supporting packages.
Step 7: Start MongoDB
Start the MongoDB service.
sudo systemctl start mongod
Enable it to start automatically after every reboot.
sudo systemctl enable mongod
Step 8: Check the Service Status
Verify that MongoDB is running.
sudo systemctl status mongod
You should see something similar to this.
Active: active (running)
Press Q to exit the status screen.
Step 9: Verify the Installation
Check the installed MongoDB version.
mongod --version
You can also verify the MongoDB shell.
mongosh --version
Step 10: Connect to MongoDB
Launch the MongoDB shell.
mongosh
If the connection is successful, you'll see a prompt similar to this.
test>
You can now start running MongoDB commands.
To exit the shell, type:
exit
Test MongoDB
Run the following command inside the MongoDB shell.
db.runCommand({ ping: 1 })
If MongoDB is working correctly, you'll receive this response.
{ ok: 1 }
Useful Commands
Restart MongoDB
sudo systemctl restart mongod
Stop MongoDB
sudo systemctl stop mongod
Check service status
sudo systemctl status mongod
View MongoDB logs
sudo journalctl -u mongod
Uninstall MongoDB
If you no longer need MongoDB, remove it using the following commands.
sudo systemctl stop mongod
sudo apt purge -y mongodb-org*
sudo rm -rf /var/log/mongodb
sudo rm -rf /var/lib/mongodb
Conclusion
You have successfully installed MongoDB Community Edition on Ubuntu 26.04. The database server is now running and ready for development or production use.
Keep in mind that this installation currently uses MongoDB's Ubuntu 24.04 repository because an official Ubuntu 26.04 repository has not been released yet. Once MongoDB publishes native packages for Ubuntu 26.04, you can switch to the official repository with only a small change to the repository configuration.

