Windows 7计算机上的MongoDB:无法建立连接 [英] MongoDB on a Windows 7 machine: No connection could be made

查看:237
本文介绍了Windows 7计算机上的MongoDB:无法建立连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 7计算机上使用mongod.exe启动Mongo之后,我尝试启动失败并显示以下错误的mongo Shell:

After I have started Mongo using mongod.exe on a Windows 7 machine, I tried to start the mongo shell that failed with the error:

无法连接到127.0.0.1:27017,原因:errno:10061否 可以建立连接,因为目标机器被主动拒绝了 它.

Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.

...

错误:无法连接到服务器127.0.0.1:27017(127.0.0.1), 尝试在src/mongo/shell/mongo.js上连接失败:146异常: 连接失败

Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146 exception: connect failed

在我运行mongod的CMD中,输出为:

In the CMD where I running the mongod the output is:

C:\ Users \ Vera> mongod --dbpath c:\ mongodb \ mongodata

C:\Users\Vera>mongod --dbpath c:\mongodb\mongodata

2014-05-18T17:10:10.135-0300 [initandlisten] MongoDB开始: pid = 3296端口= 27017 dbpath = c:\ mongodb \ mongodata 64位主机= Vera-PC

2014-05-18T17:10:10.135-0300 [initandlisten] MongoDB starting : pid=3296 port=27017 dbpath=c:\mongodb\mongodata 64-bit host=Vera-PC

2014-05-18T17:10:10.136-0300 [initandlisten] targetMinOS:Windows 7/Windows Server 2008 R2

2014-05-18T17:10:10.136-0300 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2

2014-05-18T17:10:10.136-0300 [initandlisten]数据库版本v2.6.1

2014-05-18T17:10:10.136-0300 [initandlisten] db version v2.6.1

2014-05-18T17:10:10.136-0300 [initandlisten] git版本: 4b95b086d2374bdcfcdf2249272fb552c9c726e8

2014-05-18T17:10:10.136-0300 [initandlisten] git version: 4b95b086d2374bdcfcdf2249272fb552c9c726e8

2014-05-18T17:10:10.136-0300 [initandlisten]构建信息:Windows sys.getwindowsversion(major = 6,minor = 1,build = 7601,platform = 2, service_pack ='Service Pack 1')

2014-05-18T17:10:10.136-0300 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')

BOOST_LIB_VERSION = 1_49

BOOST_LIB_VERSION=1_49

2014-05-18T17:10:10.136-0300 [initandlisten]分配器:系统

2014-05-18T17:10:10.136-0300 [initandlisten] allocator: system

2014-05-18T17:10:10.136-0300 [initandlisten]选项:{存储空间:{ dbPath:"c:\ mongodb \ mongodata"}}

2014-05-18T17:10:10.136-0300 [initandlisten] options: { storage: { dbPath: "c:\mongodb\mongodata" } }

2014-05-18T17:10:10.242-0300 [initandlisten]期刊 dir = c:\ mongodb \ mongodata \ journal

2014-05-18T17:10:10.242-0300 [initandlisten] journal dir=c:\mongodb\mongodata\journal

2014-05-18T17:10:10.243-0300 [initandlisten]恢复:无日志 文件存在,无需恢复

2014-05-18T17:10:10.243-0300 [initandlisten] recover : no journal files present, no recovery needed

2014-05-18T17:10:11.077-0300 [initandlisten]等待连接 在27017端口上

2014-05-18T17:10:11.077-0300 [initandlisten] waiting for connections on port 27017

任何建议如何解决此问题?

Any suggestion how to fix this issue?

推荐答案

解决我问题的方法是创建一个文件 startmongo.conf ,该文件将 bind_ip 设置为127.0.0.1 .之后,我只是创建了一个 *.bat 来使用以下方式启动mongo:

What solved my issue was creating a file startmongo.conf that sets the bind_ip to 127.0.0.1 . After that, I just created a *.bat to start the mongo using something like:

mongod --config c:\mongodb\bin\startmongo.conf

在此帖子中可能会看到更多详细信息.

More details could be seem at this post .

这篇关于Windows 7计算机上的MongoDB:无法建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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