【问题标题】:Whats wrong with my Mongo query?我的 Mongo 查询有什么问题?
【发布时间】:2015-07-31 05:45:51
【问题描述】:

我最近在我的 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"

谁能告诉我如何连接到服务器?

【问题讨论】:

  • 认为你的 db server 不是 startet 或者没有监听 localhost 的 27017 端口
  • 我进入我的应用程序,然后执行“npm start”,但出现错误
  • 另外,请在创建数据库管理员之前检查您是否未激活安全性(配置文件中的 auth=true)。
  • 运行ps -ef | grep mongod时看到了什么?
  • AMAC02MX3APF8J3:~ ryan.garrett$ ps -ef | grep mongod 1506864737 4888 4879 0 2:25pm ttys000 0:00.00 grep mongod

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-23
    • 2010-11-26
    • 2017-02-25
    • 2010-09-29
    相关资源
    最近更新 更多