In this blog, we will discuss how to Uninstall MongoDB on Ubuntu? If you want to clear up MongoDB from your PC then you have to remove MongoDB configuration files, data, and logs from your system. But before doing so, please ensure to take the backup of your MongoDB data on your device as this procedure is irreversible.
Also Read: Install MongoDB in Ubuntu: Everything you need
Uninstall MongoDB on Ubuntu
You have to follow the steps given below to uninstall MongoDB on your system:
Stop MongoDB Daemon Process
- Firstly, you have to stop the
`mongod`process on your PC so that you can completely uninstall the mongoDB.
- Secondly, run the following command after opening the terminal:
sudo service mongod stop
Use APT to remove MongoDB packages
When you use the command given below then the MongoDB packages will completely vanish from your system.
sudo apt-get purge mongodb-org*
How to remove MongoDB Logs?
Now we will discuss the procedure of removing the MongoDB logs. But before you can do so, you have to know the location of MongoDB logs. The logs of MongoDB are present inside
sudo rm -r /var/log/mongodb
The above-mentioned command will remove the logs and their associated sub-directories from your system.
Uninstalling MongoDB from Ubuntu
This is the last step where we will remove and uninstall the MongoDB on Ubuntu from the location of
/var/lib/mongodb/. But if there is a possibility that the MongoDB is set in a different location then you can pass your MongoDB location with the following remove command:
sudo rm -r /var/lib/mongodb
In this blog on how to uninstall MongoDB on Ubuntu, we discussed the process of removing MongoDB from Ubuntu on your system. We hope that the above-mentioned steps helped you in doing so. If you are able to delete MongoDB then share this blog with everyone who wants to do so too. Thank you for reading our blog!