1. Home
  2. MongoDB Tutorial
  3. Uninstall MongoDB from Ubuntu 20.04 LTS

Uninstall MongoDB from Ubuntu 20.04 LTS

In this tutorial, We are going to perform Completely remove/uninstall MongoDB from Ubuntu 20.04 LTS using command line.

Step 1: Stop MongoDB Service

First, Stop the MongoDB Service if it is running using below command.

$ sudo service mongod stop

OR

$ sudo systemctl stop mongod

Step 2: Uninstall MongoDB from Ubuntu 20.04 LTS

uninstall the MongoDB packages from system using below command.

$ sudo apt-get purge mongodb-org*

Output:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'mongodb-org-unstable-tools' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-mongos' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-tools' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable-server' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable-shell' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-shell' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable-mongos' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-unstable' for glob 'mongodb-org*'
Note, selecting 'mongodb-org' for glob 'mongodb-org*'
Note, selecting 'mongodb-org-server' for glob 'mongodb-org*'
Package 'mongodb-org-unstable' is not installed, so not removed
Package 'mongodb-org-unstable-mongos' is not installed, so not removed
Package 'mongodb-org-unstable-server' is not installed, so not removed
Package 'mongodb-org-unstable-shell' is not installed, so not removed
Package 'mongodb-org-unstable-tools' is not installed, so not removed
The following packages will be REMOVED:
mongodb-org* mongodb-org-mongos* mongodb-org-server* mongodb-org-shell* mongodb-org-tools*
0 upgraded, 0 newly installed, 5 to remove and 46 not upgraded.
After this operation, 296 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 176370 files and directories currently installed.)
Removing mongodb-org (4.2.8) ...
Removing mongodb-org-mongos (4.2.8) ...
Removing mongodb-org-server (4.2.8) ...
Removing mongodb-org-shell (4.2.8) ...
Removing mongodb-org-tools (4.2.8) ...
Processing triggers for man-db (2.9.1-1) ...
(Reading database ... 176322 files and directories currently installed.)
Purging configuration files for mongodb-org-server (4.2.8) ...
Purging configuration files for mongodb-org (4.2.8) ...

Step 3: Remove MongoDB log files and Data Directories

Remove the MongoDB log files.

$ sudo rm -r /var/log/mongodb

Remove the MongoDB log files.

$ sudo rm -r /var/lib/mongodb

How to Install MongoDB on Ubuntu 20.04 LTS,

How to Install MongoDB on Ubuntu 18.04/16.04 LTS

How to Download and Install MongoDB on Windows

Reference:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

Tags

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.