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

当前回答

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

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

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

然后重新开始:

brew services restart mongodb

现在工作得很好。

其他回答

删除mongod。锁文件。然后运行"mongod -repair"。卸载/重新安装mongod服务为我解决了这个问题。

谢谢。

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/

Windows操作系统处理步骤:

删除mongod。锁定文件从C:\Program Files\MongoDB\Server\4.0\data 点击C:\Program Files\MongoDB\Server\4.0\bin上的mongod 点击C:\Program Files\MongoDB\Server\4.0\bin中的mongo启动mongodb shell

如果上面所有的解决方案都不奏效,那么这个可能会有所帮助。在某个地方,您可能已经通过vagrant boxes连接到本地mongodb数据库。

Vagrant up,然后SSH到您的Vagrant机器,其中您已经与mongodb建立了连接(Vagrant SSH vagrant_box_name) 使用# (sudo nano /etc/mongo .conf)注释掉/etc/mongo .conf中的bind_ip行 重启mongodb守护进程服务(sudo service mongod Restart) 瞧……

启动monogdb服务使用

sudo service mongod start 

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

mongo