AnnouncementIntroducing MongoDB 8.0, the fastest MongoDB ever! Read more >>Introducing MongoDB 8.0, the fastest MongoDB ever! >>

To completely remove MongoDB, you have to remove the MongoDB services, MongoDB packages, the databases, and any log files. Using this guide, you will be able to uninstall MongoDB from Linux, Mac, and Windows. The basic uninstallation process is the same, with some variations in the commands depending on the operating system. Remember to keep a backup of your data, as the uninstall cannot be reversed.

Every new version of MongoDB comes with a host of new features and benefits. For example, MongoDB 7.0, the latest stable version, comes with advanced features for Atlas Search Index management, and several improvements in performance, security, migrations, developer experience, and much more. If you are planning to install a new version of MongoDB, this is the perfect in-depth guide to help you completely uninstall MongoDB (older version) and get started with the new versions.


Table of contents

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 MongoDB log files. All of this should be done from the terminal.

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

Type the following commands one by one to uninstall MongoDB:

  1. Stop MongoDB process:
sudo service mongod stop
  1. Permanently remove MongoDB packages:
sudo apt-get purge mongodb-org*
  1. Remove the data directories, MongoDB database(s), and log files:
sudo rm -r /var/log/mongodb /var/lib/mongodb
  1. To check if MongoDB is successfully uninstalled, type:
service mongod status

If you wish to reinstall MongoDB on Linux, follow the links below:

Alternatively, you can spin a free MongoDB Atlas cluster to access the MongoDB database as a service, thus avoiding the need for install/uninstall.

How to uninstall MongoDB from Mac

For uninstalling MongoDB from Mac, follow the below steps on the terminal:

  1. Check if any mongo service is running:
launchctl list | grep mongo
  1. If you had installed MongoDB using Homebrew, unload mongodb:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

rm -f ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

launchctl remove homebrew.mxcl.mongodb-community
  1. Kill the mongod process, if it exists:
pkill -f mongod
  1. If you had installed MongoDB using brew, uninstall MongoDB with the below command:
brew uninstall mongodb-community 
brew uninstall mongodb-database-tools
brew uninstall mongosh
brew untap mongodb/brew
  1. If you installed MongoDB manually (without Homebrew), then use:
rm -rf <yourmongodb_folder>

Remove database files:

rm -rf /usr/local/var/mongodb

To check if the uninstall was properly done, check if any MongoDB files are still present:

ls -al /usr/local/bin/mongo*
zsh: no matches found: /usr/local/bin/mongo*

To install a newer MongoDB version, visit Install MongoDB on Mac. Alternatively, avoid the need for install/uninstall in the future by trying free today.

How to uninstall MongoDB from Windows

For uninstalling MongoDB from Windows, use any of the following options.


Uninstall MongoDB using Settings

  1. Click on the start menu or search bar near the start menu and open system settings.

An image of opening settings on your windows screen

  1. On the settings page, double click on Apps (on the left side of the window), and then double click on installed apps.

An image of going onto to apps and then installed apps

  1. From the list of applications shown, click on the MongoDB application. You can also search in the list for MongoDB. Click on the three dots on the right side and select uninstall.

An image of clicking on the three dots and then clicking on uninstall.

Uninstall MongoDB using Control Panel (Windows 10)

  1. Open Control Panel using the Start menu or command prompt (control command).

An image of open control panel from your windows device.

  1. Once the Control Panel is open, click on “Uninstall a program” under the Programs/Programs and Features heading.

An image of clicking on uninstall a program. 3. Select and right click on MongoDB.

An image of right clicking on mongodb and click uninstall.

  1. Click on Uninstall. Windows will ask you to confirm the uninstall. Click on Yes. The above will completely remove MongoDB databases, MongoDB packages, and MongoDB data.

Whichever way you use for uninstalling MongoDB on Windows, make sure to restart your machine for the changes to reflect. You can reinstall MongoDB on Windows from the official MongoDB documentation page. Alternatively, avoid the need to install/uninstall in the future by trying MongoDB Atlas for free.

There are many reasons why you should use MongoDB Atlas, other than the fact that you don't have to install/uninstall a MongoDB database on your machine. MongoDB Atlas runs on the cloud and provides a host of features, including built-in security and automated backups. Try a free cluster today to explore the benefits.

Ready to get started?

Launch a new cluster or migrate to MongoDB Atlas with zero downtime.

FAQs

How do I remove MongoDB from Windows 10?

You can remove MongoDB from Windows 10 using many approaches, including from command prompt, Control Panel, Apps and Features, and so on. Read our guide How to uninstall MongoDB from Windows to learn the detailed steps.

How do I completely remove MongoDB from Mac?

To remove MongoDB from your Mac OS, follow the simple steps given in our in-depth How to uninstall MongoDB from Mac guide.

How do I uninstall MongoDB?

To completely remove MongoDB, you have to stop the MongoDB service and delete the related databases, log files, and directories. Refer to our guide How to uninstall MongoDB to learn the detailed uninstallation steps on Linux, Mac, and Windows OS.

How to uninstall MongoDB on Linux Mint

To uninstall MongoDB from Linux-based systems, you need superuser access. Once you have that, you can remove the MongoDB services, packages, and data directories. Each Linux distribution might differ slightly, but you can refer to How to uninstall MongoDB from Linux for detailed commands on Debian-based systems.

Where is MongoDB installed on Mac?

Once you install MongoDB on Mac using HomeBrew, you can find MongoDB-related files in the following locations:

MongoDB binaries:

/usr/local/Cellar/mongodb-community/[version]/bin/usr/local/Cellar/mongodb-community/[version]/bin

Logs:

/usr/local/var/log/mongodb/

mongod.conf file:

/usr/local/etc/mongod.conf/usr/local/etc/mongod.conf

MongoDB databases:

/usr/local/var/mongodb/data/db/usr/local/var/mongodb/data/db