Blog
{Blog}  Join us at AWS re:Invent 2022 Nov. 28 - Dec. 2 to learn how to build the next big thing on MongoDB and AWS

How to Uninstall MongoDB

To completely remove MongoDB, you have to first remove the MongoDB services, the databases, and any log files. Using this guide, you will be able to uninstall MongoDB from Linux, Mac, and Windows. 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 benefits. For example, MongoDB 5.0 comes with time-series collections, window functions, online archiving, and much more. If you are planning to install a new version of MongoDB, this is the perfect in-depth guide to help you uninstall your previous MongoDB version and get started with the new versions. We also introduce the MongoDB Atlas cluster, which provides an alternate download-free approach to use MongoDB.

Jump to Instructions for:

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.

Uninstall steps

Type the following commands one by one to uninstall MongoDB:

  1. Stop MongoDB process:

    sudo service mongod stop
  2. Completely remove the installed MongoDB packages:

    sudo apt-get purge mongodb-org*
  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

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

  • Install MongoDB on Linux
  • Install MongoDB Community Edition on Ubuntu
  • Install MongoDB Community Edition on Red Hat or CentOS

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

To completely delete any version of 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
  2. Kill the mongod process, if it exists:

    pkill -f mongod
  3. 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

If you installed MongoDB manually (without Homebrew), then use:

rm -rf <yourmongodb_folder>
  1. 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 MongoDB Atlas free today.

How to uninstall MongoDB from Windows

You can uninstall MongoDB from Windows using any of the following options.

Uninstall MongoDB using Apps and Features

  1. Open Windows Start menu and search for “Apps and Features” system settings.
  2. From the list of applications shown, click on the MongoDB application. You can also search in the list for MongoDB.
  3. Click on the MongoDB app name to uninstall.

Uninstall MongoDB using Control Panel (Windows 10)

  1. Open Control Panel using the Start menu or command prompt (control command).
  2. Once the Control Panel is open, click on “Uninstall a program” under the Programs/Programs and Features heading.
  3. Select and right click on MongoDB.
  4. Click on Uninstall.
  5. Windows will ask you to confirm the uninstall. Click on Yes.

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 for install/uninstall in the future by trying MongoDB Atlas free today.

Try MongoDB Atlas free, with no download required

There are many reasons why you should use MongoDB Atlas, other than the fact that you don’t have to install/uninstall 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

Logs: /usr/local/var/log/mongodb/

mongod.conf file:

/usr/local/etc/mongod.conf

MongoDB databases:

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