我的Mongo查询有什么问题?

时间:2015-05-19 11:54:43

标签: mongodb terminal vi hybrid-mobile-app .bash-profile

我最近在我的vi .bash_profile中为我的mongo命令设置了一条路径。我知道这很有效,因为昨天它正在运作。

但是,当我现在这样做时,我收到此错误:

AMAC02MX3APF8J3:~ james.flan$ mongo
MongoDB shell version: 3.0.3
connecting to: test
2015-05-19T11:34:58.708+0100 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-05-19T11:34:58.710+0100 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
    at connect (src/mongo/shell/mongo.js:179:14)
    at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed

以下是我的vi .bash_profile中的内容:

alias mongod="mongod --dbpath /Users/ryan.garrett/Documents/Software/MongoDB/data"
export PATH="/Users/ryan.garrett/Documents/Software/MongoDB/bin:$PATH"

有人可以告诉我如何连接服务器吗?

1 个答案:

答案 0 :(得分:1)

检查你的/ etc / hosts是否有localhost条目,并确保mongod正在监听所有接口,你可以通过netstat -an | grep mongo进行检查。