无法连接到服务器127.0.0.1 shell/mongo.js [英] couldn't connect to server 127.0.0.1 shell/mongo.js

查看:123
本文介绍了无法连接到服务器127.0.0.1 shell/mongo.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在ubuntu中设置mongodb时,我尝试:./mongo显示此错误:

when i setup mongodb in my ubuntu , i try : ./mongo it show this error :

 couldn't connect to server 127.0.0.1 shell/mongo.js

那我该怎么办

谢谢

推荐答案

  • 手动删除锁定文件:sudo rm /var/lib/mongodb/mongod.lock
  • 运行修复脚本:sudo -u mongodb mongod -f /etc/mongodb.conf --repair
    • Manually remove the lockfile: sudo rm /var/lib/mongodb/mongod.lock
    • Run the repair script: sudo -u mongodb mongod -f /etc/mongodb.conf --repair
    • 请注意以下几点:

      • 您必须以mongodb用户身份运行此命令.如果您以root身份运行, 那么root将拥有/var/lib/mongodb/中必要的文件 运行mongodb守护程序,因此在守护程序尝试运行时运行 后来作为mongodb用户,它将没有启动权限.在 在这种情况下,您会收到以下错误消息:无法创建/打开锁定文件 用于lockfilepath:/var/lib/mongodb/mongod.lock errno:13权限 被拒绝,终止.
      • 在Ubuntu上,您必须指定配置文件/etc/mongodb.conf 使用-f标志.否则,它将在 错误的位置,您将看到以下错误:dbpath(/data/db/) 不存在,终止.
      • You must run this command as the mongodb user. If you run it as root, then root will own files in /var/lib/mongodb/ that are necessary to run the mongodb daemon and therefore when the daemon trys to run later as the mongodb user, it won't have permissions to start. In that case you'll get this error: Unable to create / open lock file for lockfilepath: /var/lib/mongodb/mongod.lock errno:13 Permission denied, terminating.
      • On Ubuntu, you must specify the configuration file /etc/mongodb.conf using the -f flag. Otherwise it will look for the data files in the wrong place and you will see the following error: dbpath (/data/db/) does not exist, terminating.

      这篇关于无法连接到服务器127.0.0.1 shell/mongo.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆