NoCache

Table of Contents

Uninstall MongoDB Completely on Debian/Ubuntu-Based Linux

Cyrus Kao
Last modified on .

If you encounter some problems with your MongoDB server and try to reinstall it or just want to uninstall it. The following will cover how to purge Mongo completely (including dependencies, configuration file, logs and database storage) on Debian/Ubuntu-based Linux distros (e.g. Linux Mint, Pop!_OS, Elementary OS).

mongod
MongoDB (/usr/bin/mongod) running in the background

Stop Service

Stop the MongoDB daemon (mongod.service) so no more data will be written to the disk:

$ sudo systemctl stop mongod

Uninstallation

Uninstall MongoDB server and its related packages (tools, client, etc.) from your system:

$ sudo apt purge mongodb*

Remove the unused dependencies:

$ sudo apt autoremove

Clean Up

Although MongoDB is now uninstalled, there are still some files left to clean.

Configuration File (Optional)

Remove the configuration file (/etc/mongod.conf):

$ sudo rm -f /etc/mongod.conf

Logs (Optional)

Remove the logs in /var/log/mongodb:

$ sudo rm -rf /var/log/mongodb

Database Storage (Optional)

Remove the database storage in /data/db (default value of MongoDB's dbPath):

$ sudo rm -rf /data/db

See Also

Comments

Sign in to leave a comment.