Upgraded mongo to 2.6 using home-brew and now can&

2019-08-04 12:37发布

问题:

Running OSX 10.9.2, I just ran brew upgrade mongo which upgraded my mongo to version 2.6

As per the instructions I've run

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

But now when I run mongo it says

MongoDB shell version: 2.6.0
connecting to: test
2014-05-05T10:07:22.769+1000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2014-05-05T10:07:22.770+1000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed

Things I've tried:

  1. I've seen this covered on other SX questions and people have suggested creating a /data/db folder but this wasn't needed previously and I don't want to lose the data from my old instance of mongo. Regardless, I tried it, and chowned it to allow read/write from my user account, but that made no difference. (FYI my data lives in /usr/local/var/mongodb/ which is typical I believe for OSX.)
  2. A lot of the other questions also assume Linux rather than Mac, or they wade off into PHP land which is not relevant to me.
  3. I've also tried rebooting my Mac.

回答1:

I fixed it by forcing home-brew to restart it.

brew services restart mongodb

and voila

$ mongo
MongoDB shell version: 2.6.0
connecting to: test
>

now works a treat.