How to Install MongoDB in Ubuntu 22.04?

By Hardik Savani May 1, 2024 Category : Ubuntu

Hi Artisan,

Now, let's see a tutorial of how to install mongodb in ubuntu 22.04. you can see how to install mongodb compass in ubuntu 22.04. If you have a question about how to install mongodb 6.0 in ubuntu 22.04 then I will give a simple example with a solution. I explained simply step by step ubuntu install mongodb server.

As of my knowledge, MongoDB 6.0 has not been released yet. The latest stable version available at the moment is MongoDB 5.0. However, I can guide you through the installation process for MongoDB 5.0 on Ubuntu 22.04. Please follow the steps below:

Step 1: Import MongoDB GPG Key

Open the terminal and execute the following command to import the GPG key for MongoDB:

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

Step 2: Create an APT Source List File

Create a source list file for MongoDB by executing the following command:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

Note: Since Ubuntu 22.04 is codenamed "Jammy Jellyfish," it corresponds to the "focal" version identifier.

Step 3: Update Package Lists

Update the package lists on your system using the following command:

sudo apt update

Step 4: Install MongoDB

Finally, install MongoDB by executing:

sudo apt install mongodb-org

Step 5: Start MongoDB

Once the installation is complete, MongoDB will be automatically started. However, if you want to start it manually, use the following command:

sudo systemctl start mongod

You can now work with MongoDB on Ubuntu 22.04.

Now you can check mongodb version using following command:

mongod --version

db version v6.0.0

Build Info: {

"version": "6.0.0",

"gitVersion": "e61bf27c2sdsdsdd36e5a13c008a32d563babe2",

"openSSLVersion": "OpenSSL 1.1.1f 31 Mar 2020",

"modules": [],

"allocator": "tcmalloc",

"environment": {

"distmod": "ubuntu2004",

"distarch": "x86_64",

"target_arch": "x86_64"

}

}

Note: If MongoDB 6.0 is released in the future, please refer to the official MongoDB documentation for the updated installation steps specific to that version.

I hope it can help you...

Tags :
Shares