Issue the below command in terminal
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
The operation should respond with an OK.
if you receive an error indicating that gnupg is not installed, you can install gnupg and its dependency libraries using the following command
sudo apt-get install gnupg
Create a list file for MongoDB in Ubuntu 20.04 (Focal) as below
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
Create a list file for MongoDB in Ubuntu 18.04 (Bionic) as below
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
Create a list file for MongoDB in Ubuntu 16.04 (Xenial) as below
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
Reload local package database with below command
sudo apt-get update
Install the latest stable version of MongoDB packages by issuing below command
sudo apt-get install -y mongodb-org
Issue the below command to Confirm the installation with version number
mongod --version
Issue the below command to Start MongoDB
sudo systemctl start mongod
If you see the failed message like., Failed to start mongod.service: Unit mongod.service not found., Reload daemon by Issuing below command
sudo systemctl daemon-reload