Mongodb:连接127.0.0.1:27017失败,原因:errno:10061 [英] Mongodb: Failed to connect to 127.0.0.1:27017, reason: errno:10061

查看:95
本文介绍了Mongodb:连接127.0.0.1:27017失败,原因:errno:10061的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 mongod.cfg 文件:

bind_ip = 127.0.0.1
dbpath = C:mongodbdatadb
logpath = C:mongodblogmongo-server.log
verbose=v

这是我的 mongod 服务命令:

Here is my mongod service command:

mongod -f c:mongodbmongod.cfg --install

我大约一周前安装了 MongoDB,一切正常,但是今天当我运行 mongo 命令时,出现以下错误:

I have installed MongoDB about a week ago and it all worked fine, however today when I ran mongo command I got the following error:

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

我该如何解决这个问题? 我使用的是 Windows 8.1

解决方案:

我忘了用这个命令启动 mongodb 服务:

I forgot to start mongodb service with this command:

net start mongodb

改进的解决方案:

1) 将目录更改为根驱动器C:,然后在管理员cmd提示窗口中键入以下命令,

1) Change directory to root drive C:, and type the command below into an admin cmd prompt window,

C:mongodbinmongod.exe --config c:mongodbmongod.cfg --install

2) 然后输入 net start MongoDB 之后您应该会看到以下消息:

2) Then type net start MongoDB after which you should see the following message:

"The Mongo DB service was started successfully"

3) 然后进入控制面板Start>Administrative Tools>Services,在服务列表中向下滚动到MongoDB,将启动类型改为自动,如果你如此渴望.按确定.

3) Then go to the control panel Start>Administrative Tools>Services, scroll down to MongoDB in the list of services and change start up type to automatic, if you so desire. Press OK.

4)最后输入C:mongodbinmongo.exe,你应该会连接到Mongo测试数据库.

4) Finally type C:mongodbinmongo.exe and you should be connected to the Mongo test DB.

参考:https://www.youtube.com/watch?v=-mik4dPArCU

推荐答案

我是这样解决的,你可以在这里一步一步来:

This is how I solved it, You can follow step by step here:

MongoDB 步骤:

MongoDB Steps:

  • 下载适用于 Windows 的最新 64 位 MSI 版本的 MongoDB.

运行安装程序(.msi 文件)

Run the installer (.msi file)

将其添加到您的 PATH 环境变量中.它应该来自:C:Program FilesMongoDBServer3.0in

Add it to your PATH of environment variables. it Should be from:
C:Program FilesMongoDBServer3.0in

现在在 C:/ 中创建一个datadb"文件夹,mongodb 使用该文件夹来存储所有数据.你应该有这个文件夹:

now Create a "datadb" folder in C:/ which is used by mongodb to store all data. You should have this folder:

C:datadb

注意:这是 mongoDB 期望的默认目录位置,不要在其他任何地方创建

Note: This is the default directory location expected by mongoDB, don’t create anywhere else

.

最后,打开命令提示符并输入:

Finally, open command prompt and type:

>> mongod

你应该看到它请求权限(允许它),然后监听一个端口.完成后,打开另一个命令提示符,让前一个命令提示符运行服务器.

You should see it asking for permissions (allow it) and then listen to a port. After that is done, open another command prompt, leaving the previous one running the server.

输入新的命令提示符

>> mongo

您应该会看到它显示版本并连接到测试数据库.

You should see it display the version and connect to a test database.

这证明安装成功!=)

This proves successful install!=)

参考链接

这篇关于Mongodb:连接127.0.0.1:27017失败,原因:errno:10061的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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