How to Completely Uninstall MongoDB from Linux?

By Digamber Rawat Last updated on
Today we are going to look at how to completely uninstall MongoDB from Linux, in order to clean up mongoDB from your system you should remove mongoDB configuration files, data, and logs. This tutorial will help you to remove mongoDB application from your system But remember, before removing mongoDB from your device you must take the backup of your mongoDB data because this process is unreversible.

Uninstalling MongoDB

You can follow given below step by step methods to uninstall MongoDB.

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 /var/log/mongodb/.

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

Conclusion

In this MongoDB tutorial, we have learn to remove MongoDB from ubuntu. I hope this tutorial must have helped you. If this tutorial really helped you to delete MongoDB then you should share it with others as well.

To know more about MongoDB you can visit MongoDB website.

Digamber Rawat
Digamber Rawat

Full stack developer with a passion for UI/UX design. I create beautiful and useful digital products to solve people’s problem and make their life easy.

Hire Me