How to install MongoDB 6.0 Server on Ubuntu 22.04

MongoDB is a popular open-source NoSQL database management system known for its flexibility, scalability, and ease of use. In addition to the free MongoDB Community Edition, there is a commercial MongoDB Enterprise Edition and fully managed cloud-based database services under the name MongoDB Atlas. MongoDB is characterized by its high flexibility and almost unlimited horizontal scalability.

If you’re looking to set up a MongoDB server on your Ubuntu system, this article will help you.

1. Update Ubuntu 22.04 Packages

On your Ubuntu 22.04 server, first, run the system update command to rebuild the APT package cache created from the existing repository. The given command will also update the installed packages of the system.

sudo apt update

Also, install a few other required packages:

sudo apt-get install gnupg curl

2. Add GPG key

First, add the GPG key that will be required by the system to check the authenticity of the MongoDB packages we are going to install in this article.

curl -fsSL | \
sudo gpg -o /etc/apt/trusted.gpg.d//mongodb-server-6.0.gpg \

3. Add MongoDB Repository on Ubuntu 22.04

MongoDB is a popular Database system but packages to install it are not available directly using the default system repository of Ubuntu 22.04. Therefore, we manually add the repository of the 6.0 version on our Ubuntu 22.04 Linux.

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

After adding the repository, update the APT index cache, using:

sudo apt update

4. Install MongoDB 6.0 on Ubuntu 22.04

Our system is now ready to install MongoDB Server and its other tools such as shell, mongosh, and more. Run the below-given command in your Ubuntu 22.04 terminal.

sudo apt install mongodb-org
Install MongoDB 6.0 on Ubuntu 22.04

6. Start and Enable the MongoDB service

Once the installation is completed, let’s enable and also start the service of the Database server, so that we don’t need to run it again and again with system boot.

sudo systemctl enable --now mongod

After enabling the service, check whether it is working without any error or not.

sudo systemctl status mongod
Enable the MongoDB service

7. How to check mongo version

To check what version of the MongoDB is currently on your Ubuntu or any Linux, we can use the commands given below:

mongod --version

Whereas, to have Mongo command line simply type:


To know how to use the command line of this Database, check out its official documentation. 

8. How to Update

If any security update will be available for MongoDB version 6.0 then to get that the user just needs to run the system update command.

sudo apt update && sudo apt upgrade

9. Uninstall or Remove

Well, those who are not interested anymore in MongoDB and don’t require it, can remove the same using the below-given command:

sudo apt autoremove --purge mongodb-org

To remove the repository & GPG key, you can use the given command:

sudo rm /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo rm /etc/apt/trusted.gpg.d/mongoserver_key.gpg

Other Articles:

1 thought on “How to install MongoDB 6.0 Server on Ubuntu 22.04”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.