我来自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

当前回答

对于Windows

而不是

mongodb: / / localhost: 27017 / yourDatabase

mongodb: / / yourComputerName: 27017 / yourDatabase

例子:

mongodb: / / Gabriel-Laptop: 27017 /商店


要查找您的计算机/笔记本电脑名称,请在搜索栏中输入“查看您的计算机名称”,“设备名称”附近的名称就是您要查找的名称。


注意:我在某处读到,不建议在Windows操作系统中为MongoDB使用localhost关键字(很可能在这里)。

其他回答

我在macOS上使用brew安装后连接mongodb时遇到了同样的问题。

问题也是蒙神。Lock,但是在我安装mongodb 3.6之前,数据库目录是/usr/local/var/mongodb,它有旧文件和mongo . Lock

简单,我把我的旧数据库文件移动到不同的文件夹,并删除了/usr/local/var/mongodb中的所有内容

然后重新开始:

brew services restart mongodb

现在工作得很好。

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/

我也有同样的问题,我已经删除了E:\Mongo Data Files\db\mongod。锁文件,所以它开始工作。该问题是由于服务器不适当的关闭。所以锁文件不干净。

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

sudo service mongod start

启动monogdb服务使用

sudo service mongod start 

然后从新的窗口或终端开始使用mongo客户端

mongo