本文介绍了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 的 MongoDB 的最新 64 位 MSI 版本.

  • Download the latest 64-bit MSI version of MongoDB for Windows.

运行安装程序(.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期望的默认目录位置,不要在别处创建

.

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

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 11:22