Mongodb:无法连接到127.0.0.1:27017,原因:errno:10061 [英] Mongodb: Failed to connect to 127.0.0.1:27017, reason: errno:10061
问题描述
这是我的 mongod.cfg
文件:
bind_ip = 127.0.0.1
dbpath = C:\mongodb\data\db
logpath = C:\mongodb\log\mongo-server.log
verbose = v
这是我的 mongod
服务命令:
mongod -fc:\mongodb\mongod.cfg --install
我已经安装了MongoDB大约一个星期前,它一切正常,但今天当我运行 mongo
命令I发生以下错误:
无法连接到127.0.0.1:27017,
原因:errno:10061无连接因为目标机器主动拒绝它
我如何解决这个问题? strong> 我使用Windows 8.1
解决方案:
我忘记使用此命令启动mongodb服务:
net start mongodb
改进的解决方案:
strong>将目录更改为根驱动器
C:\
,然后在管理员cmd
提示符窗口中键入以下命令,C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg --install
2)然后键入
net启动MongoDB
之后,您应该会看到以下消息:Mongo DB服务已成功启动
3)然后转到控制面板
4)最后输入开始>管理工具>服务
,在服务列表中向下滚动到MongoDB,并将启动类型更改为自动,如果您愿意的话。C:\mongodb\bin\mongo.exe code>,您应该连接到Mongo测试数据库。
参考: https://www.youtube.com/watch?v=-mik4dPArCU
解决方案这是我如何解决它,你可以在这里一步一步:
MongoDB步骤:
下载最新的64位MSI版本的 MongoDB < a> Windows。
- > PATH 环境变量。它应该是:
运行安装程序(.msi文件)
C:\Program Files\MongoDB\Server\3.0\bin
现在在 C:/ 中创建一个\data\db mongodb 来存储所有数据。您应该具有此文件夹:
C:\data\db
注意:这是mongoDB预期的默认目录位置,
不在其他位置创建
。
最后,打开命令提示符并键入:
> ; mongod
您应该看到它请求权限(允许),然后侦听端口。
输入新的命令提示符
$ b b
>> mongo
您应该看到它显示版本并连接到测试数据库。
这证明已成功安装!=)
Here is my
mongod.cfg
file:bind_ip = 127.0.0.1 dbpath = C:\mongodb\data\db logpath = C:\mongodb\log\mongo-server.log verbose=v
Here is my
mongod
service command:mongod -f c:\mongodb\mongod.cfg --install
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
How can I fix that? I use Windows 8.1
Solution:
I forgot to start mongodb service with this command:
net start mongodb
Improved solution:
1) Change directory to root drive
C:\
, and type the command below into an admincmd
prompt window,C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg --install
2) Then type
net start MongoDB
after which you should see the following message:"The Mongo DB service was started successfully"
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) Finally type
C:\mongodb\bin\mongo.exe
and you should be connected to the Mongo test DB.Reference: https://www.youtube.com/watch?v=-mik4dPArCU
解决方案This is how I solved it, You can follow step by step here:
MongoDB Steps:
Download the latest 64-bit MSI version of MongoDB for Windows.
Run the installer (.msi file)
Add it to your PATH of environment variables. it Should be from:
C:\Program Files\MongoDB\Server\3.0\bin
now Create a "\data\db" folder in C:/ which is used by mongodb to store all data. You should have this folder:
C:\data\db
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.
Type in the new command prompt
>> 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屋!