How to uninstall MongoDB from Mac

发布时间 2023-07-28 10:32:19作者: wooHsi

To completely delete any version of MongoDB from Mac, follow the below steps on the terminal:

Check if any mongo service is running:

launchctl list | grep mongo
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
Kill the mongod process, if it exists:

pkill -f mongod
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>
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*

ref:
https://www.mongodb.com/basics/uninstall-mongodb