Published on

Installing the Latest Version of MongoDB on macOS Monterey

Last Modified on
Last modified on
Authors
Installing the Latest Version of MongoDB on macOS Monterey
Photo by Rubaitul Azad on Unsplash

It has been a while since I installed MongoDB on my Mac. In fact, the version that I had installed was Mongo 4.2.8. However, now things are done a bit differently. It is also highly encouraged to only install MongoDB with Homebrew.

If you are like me and have not installed MongoDB on your macOS for a while, and even have a version of MongoDB below 4.4, a lot has changed for us since then.

There no longer is MongoDB to install with Homebrew. According to stackoverflow, there no longer is a mongodb formula in homebrew-core:

To our users: if you came here because mongodb stopped working for you, we have removed it from the Homebrew core formulas since it was migrated to a non open-source license.

MongoDB now is a NON open-source license. Imagine that.

I used to download MongoDB using the .tgz tarball. And we had a whole bunch of steps to go through in order to place it in the right folder on our macOS. NOW, MongoDB suggests avoiding that route:

While MongoDB can be installed manually via a downloaded .tgz tarball as described in this document, it is recommended to use the brew package manager on your system to install MongoDB if possible. Using a package manager automatically installs all needed dependencies, provides an example mongod.conf file to get you started, and simplifies future upgrade and maintenance tasks.

It has always been a no-brainer for me to go the Homebrew route when installing packages on macOS, so I immediately complied. However, the sequence of commands is a bit different now as a result of the “non open-source license” change.

I did not previously install MongoDB with Homebrew, so I did not have to do the following (and neither does it work anymore):

# If you still have the old mongodb installed from homebrew-core
brew services stop mongodb
brew uninstall homebrew/core/mongodb

This was first posted Sep 11, 2019 on stackoverflow, and then updated with a link to mongodb/homebrew-brew repository on Github September 28, 2021. The link takes you to the new MongoDB Homebrew Tap on Github. It takes you through the steps to install the MongoDB community version as opposed to the premium Enterprise Edition.

I did the following:

# Use the migrated distribution from custom tap
brew tap mongodb/brew
brew update (always recommended before installing something new)
brew install mongodb-community
brew services start mongodb-community

And I was good to go! I still have the old Mongo 4.2.8 version installed on my OS, but it does not work. It is obsolete. This will be the next thing to figure out. How do I uninstall it, if at all possible?