Installing MongoDB Community Server on Ubuntu 20.04 LTS
Ubuntu on Windows Subsystem for Linux cannot use this method because systemd is not enabled.
- Import MongoDB GnuPG public key
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
- Insert a repository entry in APT source list
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
- Update apt package list
sudo apt-get update
- Install MongoDB server by issuing command:
sudo apt-get install -y mongodb-org
- Run MongoDB server as a service
sudo systemctl start mongod
- Verify that MongoDB server is installed and running:
sudo systemctl status mongod
Sample output if the service is running:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2021-05-15 19:45:54 AEST; 3s ago
Docs: https://docs.mongodb.org/manual
Main PID: 5730 (mongod)
Memory: 59.6M
CGroup: /system.slice/mongod.service
└─5730 /usr/bin/mongod --config /etc/mongod.conf
May 15 19:45:54 ricky-ubuntu-vm systemd[1]: Started MongoDB Database Server.