How to Uninstall MongoDB in Ubuntu Linux

How to uninstall MongoDB from Ubuntu Linux

To uninstall MongoDB from Linux, you have to stop the daemon process, and remove the MongoDB applications, configuration files, data files, and log files. All of this should be done from the terminal.

Prerequisites

You must have sudo access, i.e., a superuser. To get sudo access, log in as an admin and add yourself to the sudo group.


In Ubuntu, the recommended way to execute commands as root or gain root access is by using the sudo command.

Uninstall steps

Type the following commands one by one to uninstall MongoDB:

STEP 1: Stop MongoDB process:

sudo service mongod stop

STEP 2 : Completely remove the installed MongoDB packages:

sudo apt-get purge mongodb-org*

STEP 3: Remove the data directories, MongoDB database(s), and log files:

sudo rm -r /var/log/mongodb /var/lib/mongodb

To check if MongoDB is successfully uninstalled, type: 

service mongod status


Related Posts