Follow this guide for installing Mongodb v.4.4.10 locally.
- Import the public Key
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
- Create a list file for mongodb
For Ubuntu 20.04 (Focal)
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
- Reload local package database
sudo apt-get update
- Install v.4.4.10
sudo apt-get install -y mongodb-org=4.4.10 mongodb-org-server=4.4.10 mongodb-org-shell=4.4.10 mongodb-org-mongos=4.4.10 mongodb-org-tools=4.4.10
This will install v.4.4.10
Optional. Although you can specify any available version of MongoDB, apt-get will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, you can pin the package at the currently installed version:
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
Run Mongodb Community Edition
- Start MongoDB
sudo systemctl start mongod
- Verify that MongoDB has started successfully.
sudo systemctl status mongod
You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
sudo systemctl enable mongod
- Stop MongoDB
sudo systemctl stop mongod
- Restart Mongodb
sudo systemctl restart mongod
- Begin using MongoDB
mongo
Uninstalling Mongdb
Uninstall previous mongodb:
- Stop Mongodb
sudo service mongo stop
- Remove Mongodb Packages
sudo apt-get purge mongodb-org*
Auto remove unused packages..
sudo apt autoremove
- Remove Data Directories
Remove MongoDB databases and log files
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
For reference – https://docs.mongodb.com/v4.4/tutorial/install-mongodb-on-ubuntu/