25

I am running these simple commands on mac:

brew upgrade mongodb 

or

brew install mongodb

I am getting this error below:

Error: mongodb: unknown version :mountain_lion

If i run the simple command: mongo , i get this

MongoDB shell version v4.0.3

But then I get an error saying couldn't connect to server

-- worth to note, I was playing around with the command line last night and somehow deleted all of my databases from mongodb on my machine(i think). I continuously get the above error when trying install and/or update mongodb.

I am "new" to mongoDB, but I have created a few full stack projects using it over the last 5-6 months. Not sure what I did, but I also can't run node db/seeds.js either as I get errors, even though I have the data in my vscode projects.

Thanks for the help.

  • 1
    Mountain Lion sounds really old (more than ~ 4 years old). Is an update feasible? I don't think the Homebrew folk actually cares about not breaking old OS X / macOS releases. [Change my mind.] – 174140 Sep 2 '19 at 22:11
  • @uprego I'm confused because my computer says that I am running macOS High Sierra version 10.13.6. – Tray Fleary Sep 2 '19 at 22:44
  • Odd. Try not only upgrade and install, but reinstall too, and eventually complete purge and install back too. If all of these fail, I guess you can always build from sources. – 174140 Sep 3 '19 at 0:13
  • @uprego None of these worked. By "you can always build from sources", what exactly is this referring to? I am still early in my development career, so thanks for the help. Also, I ran mongod in one tab, and then my projects allowed me to re-seed my database in another tab. Thats confirmation that I deleted them, but my big question is, do I always have to run 'mongod'? In the past, I could open my command line, cd into a certain project, and easily run 'mongo', 'show dbs', "use 'collection'", 'db.collection.find().pretty()' to see my data with no problem, or db.dropDatabase() for that matter. – Tray Fleary Sep 3 '19 at 1:25
  • You can always build from sources means you can always build from sources. I can't help mongod troubleshooting. Beware your use questions about mongod belong in a different question than this about installing MongoDB. – 174140 Sep 3 '19 at 1:37
59

Formula mongodb has been removed from homebrew-core. Check pr-43770 from homebrew-core

To our users: if you came here because mongodb stopped working for you, we have removed it from the Homebrew core formulas since it was migrated to a non open-source license.

Fortunately, the team of mongodb maintained a custom Homebrew tap. You can uninstall the old mongodb and reinstall the new one from the new tap.

brew services stop mongodb
brew uninstall mongodb

brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community

Check mongodb/homebrew-brew for more info.

  • Thank you for the reply. – Tray Fleary Sep 16 '19 at 17:45
  • to start run 'brew services start mongodb-community' – Davide Carpini Oct 10 '19 at 13:48
  • @DavideCarpini Thanks. Service related commands are added. – Simba Oct 10 '19 at 14:50
  • @Simba thanks for detailed answer – Hattori Hanzō Jan 3 at 14:33
10

MongoDB is maintaining an homebrew tap. So, I think it's the recommanded way to setup mongodb. If you're running mongodb from the homebrew tap, both are using the same config and db files, so it's safe to change the mongodb install.

# -> Firstly, it's a good reflex to run the following command, to ensure that you don't have any other error
brew doctor
# -> Secondly, ensure that mongodb is not running, in your case, this command will return, probably, "mongodb: unknown version :mountain_lion"
brew services stop mongodb
# -> Install the homebrew tap
brew tap mongodb/brew
# -> Uninstall old homebrew, maybe you will have to rerun this command later with --force flag
brew uninstall mongodb
# -> Install mongodb from mongodb tap
brew install mongodb-community
# -> Ensure that you can access your db, and everything is working, then you can run uninstall again with --force flag.
0

mongodb was removed from brew, so you should do the following:

1) which mongo if you want to verify your installation

2) brew uninstall mongodb

3) brew install mongodb-community

4) brew services start mongodb-community

and ready!!!

  • 1
    Your answer is same as previous answer. – Simba Sep 27 '19 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.