Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install earlier version of mongodb with homebrew?

I'm on osx6.8 and need to install an earlier version of Mongodb, how do I install an earlier version with HomeBrew?

The below didn't work :(

dream-2:app2 star$ brew install mongodb-2.6.10 Error: No available formula for mongodb-2.6.10  Searching formulae... Searching taps... dream-2:app2 star$  

Edit:
I'm getting a message to explain how this post is unique compared to another one, well, the answer to the other question is super long and complex and it's specific to postgresql and doesn't really answer my question.

like image 916
Agent Zebra Avatar asked May 21 '15 16:05

Agent Zebra


People also ask

Where MongoDB is installed on Mac?

The databases are stored in the /usr/local/var/mongodb/ directory. The mongod. conf file is here: /usr/local/etc/mongod.

Which version of MongoDB is compatible with Windows 7?

Determine which MongoDB build you need. The following MongoDB builds are available for Windows: MongoDB for Windows 64-bit runs only on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows.


2 Answers

Note: In September 2019 mongodb was removed from homebrew core, so these instructions have been updated to use mongodb-community instead, installed from the external tap.

If your current installation is still the pre-September mongodb package 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-community 

But 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 mongod 

Now I want 3.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 3.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-line 

When 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.

like image 136
joeytwiddle Avatar answered Oct 01 '22 16:10

joeytwiddle


When trying to install old versions of something with homebrew, it's usually useful to start with brew search packagename, in this case, there's a 2.6 version available under homebrew/versions/mongodb26

So, to install that version:

brew install homebrew/versions/mongodb26 

Edit

This answer has certainly become very dated. Take a look at the answer below for a valid way to accomplish this in 2021.

like image 34
Cody Haines Avatar answered Oct 01 '22 16:10

Cody Haines