How To Install MongoDB community edition on Ubuntu 20.04–22.04

  1. Import the public key used by the package management system.
wget -qO — https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
sudo systemctl daemon-reload
sudo systemctl start mongod
sudo systemctl status mongod
mongod — version
mongosh
  1. To list existing databases
show dbs
db
use blog

Error Solution of Ubuntu 22.04:

  1. Download libssl1.1_1.1.1f-1ubuntu2_amd64.deb from the official repository:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo apt-get install -y mongodb-org

--

--

Senior Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store