35

I have version 2.0.2 of mongo installed on my mac, which I installed using Homebrew. The course I'm taking is using the 'aggregate' function, which is only available in version 2.2 of Mongo. I tried to do

 brew upgrade mongodb

and I get

Error: mongodb already upgraded

Is there a way to install the latest version of Mongo with Homebrew?

Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134

5 Answers5

79

If the version of mongodb in your brew receipe is the same of the version installed, you get the stated error.

Typically when you see a latest stable version released and you wish to bump up your mongodb version to it, you'd first have to update your brew receipe and then do your upgrade as you did.

That means you'd first do

brew update

and then

brew upgrade mongodb
karthiks
  • 7,049
  • 7
  • 47
  • 62
  • It worked great for me, but it took an astonishing 27 minutes to complete... Does it also upgrade the DB files? Mine has about 4GB of data and 5M docs. – Nico Nov 06 '17 at 15:28
  • It usually is not about the Db files. What I suspect you did is you would have typed brew upgrade instead of brew update. The former upgrades all your brew installed apps. You may try checking CLI history for confirmation. – karthiks Nov 06 '17 at 20:31
61

This command should update your homebrew formulae to their latest version:

brew update

And then:

brew upgrade mongodb-community

To install the latest version of mongodb.

DauleDK
  • 3,313
  • 11
  • 55
  • 98
edouardbriere
  • 1,170
  • 8
  • 12
11

for MacOS Catalina and above

First, you install Homebrew. If you’re curious about what Homebrew is, read this article.

# Installs Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Second, find the MongoDB tap.

brew tap mongodb/brew

Third, install MongoDB.

brew install mongodb-community
kheengz
  • 840
  • 12
  • 10
  • 3
    This is the right answer, as `mongodb` recipe has been removed from Homebrew because Mongo team migrated to a non open-source license: https://github.com/Homebrew/homebrew-core/pull/43770 – raulmarcosl May 06 '20 at 03:57
0

You should be able to run: brew upgrade mongodb

now and it'll update prior to upgrading your version of mongodb.

0

I tried the above solutions, but none of them worked. I got the error message:
no available formula or cask with the name "mongodb". Did you mean mongosh or monetdb? . I found a solution at this link.

Stackoverflow solution for No available formula or cask"

stromyc
  • 488
  • 6
  • 13