脚步:
brew update
brew install mongodb
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
mongo
输出:
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
按照无法在 OS X Yosemite(10.10.2)上通过 launchctl 启动 mongodb我也尝试过:
brew tap gapple/services
brew services start mongodb
但遇到了同样的问题。但是如果我这样做
mongod
然后在另一个 shell 中,它工作正常:
mongo
MongoDB shell version: 3.2.4
connecting to: test
>
答案1
我在我的机器上尝试多次解决这个问题,所以我找到了正确的解决方案:这里
特别感谢@gorjanz。
答案2
我遇到了类似的问题,这对我有帮助:
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
rm -f ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
brew uninstall mongodb
# double check existence
ls -al /usr/local/bin/mong*
ls -al ~/Library/LaunchAgents
rm -R /usr/local/var/mongodb