Note: In September 2019
mongodbwas removed from homebrew core, so these instructions have been updated to usemongodb-communityinstead, installed from the external tap.If your current installation is still the pre-September
mongodbpackage then you will need to use that name when you unlink, stop, relink and start, on the lines marked with#*#below.Another option is to simply upgrade away from the deprecated package now.
I already have the latest version of mongo installed, thanks to.
brew tap mongodb/brew
brew install mongodb-communityBut I want to switch to the old version sometimes. First, install it:
brew search mongo
brew install [email protected]Let's stop the current mongodb, if it is running:
brew services stop mongodb/brew/mongodb-community #*#
# or if you had started it manually
killall mongodNow I want 4.2 on my PATH instead of the latest:
brew unlink mongodb-community #*#
brew link --force [email protected](Apparently it needs --force because it is keg-only.)
Now I have 4.2 on my PATH, I can start the test DB:
mongod --version
brew services start mongodb/brew/mongodb-community
# or start your own mongod from the command-lineWhen I am finished, I can do the reverse to switch back to the latest version:
brew services stop mongodb/brew/mongodb-community
brew unlink [email protected]
brew link mongodb-community #*#
brew services start mongodb/brew/mongodb-community #*#And restart again.