In this tutorial, We are going to perform uninstall MongoDB on Ubuntu 18.04/16.04 LTS in 3 steps 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 on Ubuntu
uninstall the MongoDB packages from system using below command.
$ sudo apt-get purge mongodb-org*
Output:
(Reading database ... 471019 files and directories currently installed.) Removing mongodb-org (4.0.6) ... Purging configuration files for mongodb-org (4.0.6) ... Removing mongodb-org-mongos (4.0.6) ... Removing mongodb-org-server (4.0.6) ... Purging configuration files for mongodb-org-server (4.0.6) ... insserv: Script auoms is broken: incomplete LSB comment. insserv: missing `Required-Start:' entry: please add even if empty. insserv: missing `Required-Stop:' entry: please add even if empty. Removing mongodb-org-shell (4.0.6) ... Removing mongodb-org-tools (4.0.6) ... Processing triggers for man-db (2.7.5-1) ...
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 18.04/16.04 LTS
How to Download and Install MongoDB on Windows
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/