How to uninstall mongosh and the MongoDB database tools on a Mac
brew refuses to remove mongosh while the MongoDB server depends on it. How to remove the shell, the 126 MB of database tools, and its history file.
How do I uninstall mongosh on a Mac?
Decide whether the MongoDB server stays.
- Removing MongoDB entirely: follow uninstalling MongoDB, then remove the shell and tools:
brew uninstall mongosh mongodb-database-tools. - Keeping the server, removing only the shell:
brew uninstall --ignore-dependencies mongosh. The server still runs; you lose the shell until you reinstall it.
On our Mac, brew uses --installed mongosh named mongodb/brew/mongodb-community, which is why a plain uninstall is refused.
What do mongosh and the tools take?
| Item | Size here | What it is |
|---|---|---|
Homebrew mongosh 2.5.1 | 99 MB | The MongoDB shell |
Homebrew mongodb-database-tools | 126 MB | mongodump, mongorestore, mongoexport and others |
~/.mongodb | 1.2 MB | mongosh history and settings |
~/.mongodb/mongosh holds your shell history, which can include connection strings with passwords if you typed them in full. Delete the folder with the shell.
Does uninstalling mongosh delete my databases?
No. Databases live in the server's data folder, /opt/homebrew/var/mongodb with Homebrew. The shell holds none of your data.
Find what is left in one look
Free Mac shows Homebrew's Cellar and ~/.mongodb on the Storage map and moves what you pick to the Trash. Database folders are covered in database data directories.
Related: uninstall fzf and uninstall CMake.
Common questions
Why won't brew uninstall mongosh?
Because mongodb-community depends on it. Remove the server first, or run brew uninstall --ignore-dependencies mongosh to keep the server.
Where is mongosh history stored on a Mac?
In ~/.mongodb/mongosh. It can include connection strings, so delete it when you remove the shell.
Does removing mongosh delete my MongoDB data?
No. Data lives in the server's data folder, /opt/homebrew/var/mongodb with Homebrew.