我最近用 Homebrew 安装了 mongodb-2.6.0 .
成功安装后,我尝试使用 mongo
命令进行连接。我收到以下不允许我连接的错误:
Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
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
最佳答案
当 mongodb 服务未在 mac 上运行时,可能会发生这种情况。要开始它,我试过了
brew services start mongodb
它成功了。
编辑:根据关于 Homebrew 软件的 PR 的讨论:https://github.com/Homebrew/homebrew/issues/30628
brew services
已弃用,我环顾四周,发现这些答案现在回答了这个问题:What is the correct way to start a mongod service on linux / OS X?
https://stackoverflow.com/questions/23418134/