我来自riak和redis,在那里我从未有过这个服务启动或互动的问题。

这是蒙古人普遍存在的问题,我对此一无所知。重启也无济于事。我是蒙哥的新手。

mongo
MongoDB shell version: 2.2.1
connecting to: test
Fri Nov  9 16:44:06 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

这是我在日志里看到的。

 now open)
Fri Nov  9 16:44:34 [conn47] end connection 10.29.16.208:5306 (1 connection now open)
Fri Nov  9 16:45:04 [initandlisten] connection accepted from 10.29.16.208:5307 #48 (2 connections now open)
Fri Nov  9 16:45:04 [conn48] end connection 10.29.16.208:5307 (1 connection now open)
Fri Nov  9 16:45:04 [initandlisten] connection accepted from 10.29.16.208:5308 #49 (2 connections now open)
Fri Nov  9 16:45:04 [conn49] end connection 10.29.16.208:5308 (1 connection now open)
Fri Nov  9 16:45:34 [initandlisten] connection accepted from 10.29.16.208:5316 #50 (2 connections now open)
Fri Nov  9 16:45:34 [conn50] end connection 10.29.16.208:5316 (1 connection now open)
Fri Nov  9 16:45:34 [initandlisten] connection accepted from 10.29.16.208:5317 #51 (2 connections now open)
Fri Nov  9 16:45:34 [conn51] end connection 10.29.16.208:5317 (1 connection now open)
Fri Nov  9 16:46:04 [initandlisten] connection accepted from 10.29.16.208:5320 #52 (2 connections now open)
Fri Nov  9 16:46:04 [conn52] end connection 10.29.16.208:5320 (1 connection now open)
Fri Nov  9 16:46:04 [initandlisten] connection accepted from 10.29.16.208:5321 #53 (2 connections now open)
Fri Nov  9 16:46:04 [conn53] end connection 10.29.16.208:5321 (1 conn

当前回答

我在ubuntu上得到这个错误,但你可以尝试以下命令:

sudo service mongod start

其他回答

Resolved. This problem could be solved by the below mentioned 4 steps 1) Remove .lock file sudo rm /var/lib/mongodb/mongod.lock 2) repair the mongodb mongod -–repair 3) start the mongod server sudo service mongod start 4) start the mongo client mongo For more details take a look at http://shakthydoss.com/error-couldnt-connect-to-server-127-0-0-127017-srcmongoshellmongo-js-exception-connect-failed/ http://shakthydoss.com/technical/error-couldnt-connect-to-server-127-0-0-127017-srcmongoshellmongo-js-exception-connect-failed/

你必须通过cmd访问你的src C: \ Program Files \ MongoDB \ Server \ 4.4 \ bin,然后你必须打开任务管理器->服务->(选择MongoDB) ->启动它,并通过cmd重新测试,它将得到解决。

这工作我:-

以Mongodb 3.2为窗口,启动Mongodb服务。因此,以管理员身份运行命令提示符,然后net start MongoDB

首先,转到c:\mongodb\bin>打开mongodb,如果你在控制台上看到mongodb正在监听端口27017,那就OK了 如果不是,关闭控制台并创建文件夹c:\data\db并重新启动mongod

确保你的mongo在运行。 我通过尝试修复mongodb来修复这个问题,在那里我发现db运行所需的目录没有创建。它显示了这个错误

类型:mongod,它将显示错误

initAndListen: 29 Data directory / Data /db not found.日志含义,终止

dbpath /data/db/(默认配置)不存在导致错误。创建数据文件夹并设置权限。

然后通过命令在我的系统上创建一个文件夹

Sudo mkdir -p /data/db/ 而且 Sudo chown id -u /data/db

然后我再次运行mongo,它工作了。