2015-05-19 68 views
0

我最近在我的vi .bash_profile中为我的mongo命令设置了一条路径。我知道这是有效的,因为它昨天工作。我的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" 

可有人请告诉我如何连接到服务器?

+0

认为你的数据库服务器不是startet或者不在本地主机上监听端口27017 – Jens

+0

我进入我的应用程序,我和'npm start'只是得到错误 – TheGarrett

+0

另外,检查你没有激活安全性(auth =在创建数据库管理员之前,在配置文件中为true)。 – Snorky35

回答

1

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