无法连接到mongodb错误:无法通过src/mongo/shell/mongo.js:L112连接到服务器127.0.0.1:27017

无法连接到mongodb错误:无法通过src/mongo/shell/mongo.js:L112连接到服务器127.0.0.1:27017

问题描述:

每当我尝试连接到mongo db时,总会出现以下错误.

When ever I try to connect to mongo db I always get this error as below.

MongoDB Shell版本:2.4.3 连接到:测试 Fri Apr 26 14:31:46.941 JavaScript执行失败:错误:无法通过src/mongo/shell/mongo.js:L112连接到服务器127.0.0.1:27017 例外:连接失败

MongoDB shell version: 2.4.3 connecting to: test Fri Apr 26 14:31:46.941 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 exception: connect failed

我尝试了*中列出的各种解决方案,并尝试了以下命令,但没有任何效果.

I tried various solutions listed in * and tried following commands but nothing works.

1)sudo rm/var/lib/mongodb/mongod.lock

1) sudo rm /var/lib/mongodb/mongod.lock

//表示这样的文件位于此位置.

// says such file located at this place.

2)sudo服务mongodb start

2) sudo service mongodb start

//错误:sudo:服务:找不到命令

// error: sudo: service: command not found

3)我确保该端口上没有其他运行.

3) I've made sure nothing else is running at that port.

4)甚至尝试再次卸载并安装它.

4) Even tried uninstalling and installing it again.

5)还尝试杀死pid

5) Also tried kill pid

这里有同样的错误,对我有用:

Same error here, this worked for me:

sudo mongod --repair

之后

sudo mongod

(忘记服务 start )

然后在其他选项卡/终端上:

Then on a different tab/terminal:

mongo