How To Uninstall MongoDB from Windows and Ubuntu
It provides the steps to remove or uninstall MongoDB from Windows and Ubuntu.
This tutorial provides the steps required to uninstall MongoDB from Windows and Ubuntu systems. Make sure that you have backed-up all your MongoDB databases before starting this tutorial.
Uninstall from Windows - Command Line
Notes: In case you have installed MongoDB using the MSI installer, you can move to the next section.
Open the Command Line Tool as Administrator and execute the below-mentioned command to remove the MongoDB service from Windows.
# Remove MongoDB Service
<MongoDB Path>\bin\mongod.exe --config <MongoDB Path>\bin\mongod.cfg --remove
C:\MongoDB\bin\mongod.exe --config C:\MongoDB\bin\mongod.cfg --remove
Now simply delete the MongoDB directory. In the above example, it is C:\MongoDB.
Uninstall from Windows - Applications
This section provides the steps to uninstall or remove MongoDB Community Edition installed using the MongoDB Installer wizard. Now, go to your System Settings Panel and click the Apps Option. Scroll on the Right Panel to find the MongoDB on the list as shown in Fig 1.
Now, click the MongoDB as highlighted in Fig 1. It shows the options to uninstall as shown in Fig 2.
Click the Uninstall Button to start uninstalling or removing MongoDB from Windows 10. It will show a pop-out to confirm uninstalling MongoDB on Windows.
Click the Uninstall Button to start the uninstallation. It might ask for system permissions to complete uninstalling MongoDB on Windows. Allow the installer to complete the process. The installer will show the progress as shown in Fig 4.
MongoDB will be removed from the Applications List on completion of the uninstallation process. Similarly, we can also remove the MongoDB Compass from Windows.
Uninstall from Ubuntu
This section provides the steps to uninstall MongoDB from Ubuntu. Similar to Windows, take the backups of existing databases if required before starting uninstalling MongoDB from the Ubuntu systems.
Stop MongoDB using the commands as shown below.
# Stop MongoDB Service
sudo service mongod stop
sudo systemctl stop mongod
Now uninstall or remove MongoDB from Ubuntu using the commands as shown below.
# Remove MongoDB packages
sudo apt-get purge mongodb-org*
Also, remove the logs and additional files using the commands as shown below.
# Remove Logs and additional files
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
This tutorial provided all the steps required to uninstall or remove the MongoDB database from Windows and Ubuntu systems.