Upgrading MongoDB 3.6 to 4.2 with brew

As cited on the official release notes:

To upgrade an existing MongoDB deployment to 4.2, you must be running a 4.0-series release.

So, a little bit of context:

Let’s say you are currently running on version 3.6.

You want to upgrade to the latest version.

You would be inclined to directly upgrade from 3.6 to 4.2.

Not so fast.

Upgrading from mongodb to [email protected]

Set the feature compatibility version by entering the current mongo shell:

db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )

Uninstall the current mongodb installation

brew uninstall mongodb

Tap the updated brew, just in case:

brew tap mongodb/brew

Install the 4.0 version:

brew install [email protected]

brew services should now list mongodb-community as a running service.

Name              Status  User      Plist
mongodb-community started christian /Users/christian/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

Uninstall 4.0 and install 4.2

brew uninstall [email protected]
brew install [email protected]

Again, brew services should list the running mongodb-community service.

Fix broken / lost executables

If you’re missing the mongo executable, fix it by symlinking it via brew:

brew link [email protected] --force


Here, have a slice of pizza 🍕