Skip to content

How to uninstall MongoDB on a Mac, and the logs that outgrew the data

MongoDB from Homebrew is three packages, a data folder and a log folder. On our Mac the logs were larger than the databases. How to remove all of it.

5 min read

How do I uninstall MongoDB installed with Homebrew?

brew services stop mongodb-community
brew uninstall mongodb-community mongosh mongodb-database-tools
brew untap mongodb/brew

MongoDB comes as separate packages. On our Mac: the server mongodb-community 7.0.11 (268 MB), the shell mongosh (99 MB) and mongodb-database-tools (126 MB). Removing only the first leaves the other two.

Where does MongoDB keep its data and logs on a Mac?

WhatWhereSize here
Databases/opt/homebrew/var/mongodb202 MB
Logs/opt/homebrew/var/log/mongodb215 MB
Settings/opt/homebrew/etc/mongod.conf4 KB
Shell history and settings~/.mongodb1.2 MB
Background launcher~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist4 KB

None of these are removed by brew uninstall. Export anything you need with mongodump first, then move them to the Trash.

Why are MongoDB's logs so big?

The server writes a log line for every connection and slow query, and on a Homebrew install nothing rotates the file. Left running for months, the log grows past the data it describes, as ours had.

Other databases on the same Mac: MySQL and PostgreSQL.

Common questions

How do I uninstall MongoDB on a Mac?

Run brew services stop mongodb-community, then brew uninstall mongodb-community mongosh mongodb-database-tools, then remove its data and log folders in /opt/homebrew/var.

Where is MongoDB installed on Mac?

With Homebrew, the program is in /opt/homebrew/Cellar, the data in /opt/homebrew/var/mongodb and the logs in /opt/homebrew/var/log/mongodb.

Read next