How to have two different versions of MongoDB installed at same time?
I know this is an old question but I was looking for a way to have version 4.x and 3.x and found this to be the easiest solution.

Install the versions of MongoDB you want with brew.

You can find which versions are available with brew search mongo. If you don't see the version you want run brew update. I'm installing the latest version (4) and version 3.6:

brew install mongodb
brew install mongodb@3.6


Start the version you want with brew service

brew services start mongodb


Switch to a different version:


Make sure you are backwards compatible: 

mongo --eval 'db.adminCommand({setFeatureCompatibilityVersion: "3.6"})'
Stop mongod:

brew services stop mongodb
Unlink the current version of MongoDB:

brew unlink mongodb
Link the new version of MongoDB:

brew link --force mongodb@3.6
Start MongoDB version 3.6:

brew services start mongodb@3.6
Check your version:

mongo --version