You can follow given below step by step methods to uninstall MongoDB.
Table of Contents
Stop MongoDB Daemon Process
First, you must stop the
`mongod` process in your system to completely uninstall the mongoDB:
Open the terminal and run the command:
sudo service mongod stop
Use APT to Remove MongoDB Packages
Using the given below command will completely remove the MongoDB packages from your system.
sudo apt-get purge mongodb-org*
How to Remove MongoDB Logs?
In this step, we are going to tell you how to remove the mongoDB logs. We must know the mongoDB log location before removing them. MongoDB logs are kept inside
sudo rm -r /var/log/mongodb
Given above command will remove the logs and its associated sub-directories.
Uninstalling MongoDB from Ubuntu
In this final step, we will remove the MongoDB from ubuntu from the following location
/var/lib/mongodb/. However, if you have set MongoDB in any other location then you can pass your MongoDB location along with the remove command:
sudo rm -r /var/lib/mongodb