Steps:
brew update
brew install mongodb
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
mongo
Output:
MongoDB shell version: 3.2.4
connecting to: test
2016-04-12T20:53:47.253+0100 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2016-04-12T20:53:47.253+0100 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6
exception: connect failed
As per Can't start mongodb by launchctl on OS X Yosemite (10.10.2) I also tried:
brew tap gapple/services
brew services start mongodb
But got the same problem. However if I just do
mongod
and then in another shell, it works fine:
mongo
MongoDB shell version: 3.2.4
connecting to: test
>