MongoDB is an open-source database management system that stores data in JSON-like formats. MongoDB’s main feature is its flexible data model, which allows users to store unstructured data with full indexing support and replication via rich and intuitive APIs.
Overview
Using the apt package manager, follow this tutorial to install MongoDB 6.0 Community Edition on Ubuntu Linux LTS (long-term support) releases.
MongoDB Version
We are going to install MongoDB 6.0 Community Edition.
Installation Steps
- 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 -
The above command should respond with an OK.
- Create a list file for MongoDB.
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
- Reload local package database.
sudo apt-get update
- Install the MongoDB packages.
sudo apt-get install -y mongodb-org=6.0.3 mongodb-org-database=6.0.3 mongodb-org-server=6.0.3 mongodb-org-mongos=6.0.3 mongodb-org-tools=6.0.3
- Start the service.
sudo service mongod start
- Verify that MongoDB has started successfully.
sudo service mongod status
You will get MongoDB service in a running state and with this the installation is complete.
Let’s see how to uninstall the MongoDB
- Stop MongoDB
sudo service mongod stop
- Remove Packages
sudo apt-get purge mongodb-org*
- Remove Data Directories
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
This will remove all the data, logs and configuration files as well.
Conclusion
You have learned in this blog how easy it is to install or uninstall MongoDB.
MtroView team is giving its best & working hard to provide the content to help you understand things better in simple terms. We are heartily open to receiving suggestions to improve our content to help more people in society. Please write to us in a comment/send an email to mtroview@gmail.com