To uninstall MongoDB from Ubuntu, first stop the Mongo Daemon if it is already running, remove MongoDB packages using APT (Advanced Package Tool), and finally remove the MongoDB logs from log directory, and MongoDB Databases from library.
Followign are the consolidated commands to uninstall MongoDB
|sudo servicemongod stop sudo apt-get purgemongodb-org* sudo rm -r /var/log/mongodb sudo rm -r /var/lib/mongodb|
Following is a detailed step by step process to uninstall MongoDB. Open a Terminal and run the mentioned
Run the following command in a Terminal.
sudo servicemongod stop
Stopping Mongo Daemon ensures that there are no locks on any database files or such.
Running the following command removes all the installed packages for MongoDB.
sudo apt-get purgemongodb-org*
Any logs for MongoDB, by default, is written to the location /var/log/mongodb/. Remove /var/log/mongodb/ and its sub-directories recursively.
sudo rm -r /var/log/mongodb
Remove MongoDB databases.
Any databases created in MongoDB, by default, is written to the location /var/lib/mongodb/. Remove /var/lib/mongodb/ and its sub-directories recursively.
sudo rm -r /var/lib/mongodb
If you have created any other directories for MongoDB databases, you may also remove them.
In this MongoDB Tutorial, we have learnt to completely uninstall MongoDB from Ubuntu.