database Mongodb:无法连接到 127.0.0.1:27017,原因:errno:10061
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26585433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mongodb: Failed to connect to 127.0.0.1:27017, reason: errno:10061
提问by Michael
Here is my mongod.cfg
file:
这是我的mongod.cfg
文件:
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
服务命令:
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:
我大约一周前安装了 MongoDB 并且一切正常,但是今天当我运行mongo
命令时出现以下错误:
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
我该如何解决?我使用 Windows 8.1
Solution:
解决方案:
I forgot to start mongodb service with this command:
我忘了用这个命令启动 mongodb 服务:
net start mongodb
Improved solution:
改进的解决方案:
1)Change directory to root drive C:\
, and type the command below into an admin cmd
prompt window,
1)将目录更改为根驱动器C:\
,然后在管理员cmd
提示窗口中键入以下命令,
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:
2)然后键入,net start MongoDB
之后您应该会看到以下消息:
"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.
3)然后转到控制面板Start>Administrative Tools>Services
,向下滚动到服务列表中的 MongoDB 并将启动类型更改为自动,如果您愿意的话。按确定。
4)Finally type C:\mongodb\bin\mongo.exe
and you should be connected to the Mongo test DB.
4)最后输入C:\mongodb\bin\mongo.exe
,你应该连接到 Mongo 测试数据库。
Reference: https://www.youtube.com/watch?v=-mik4dPArCU
回答by Chee Loong Soon
This is how I solved it, You can follow step by step here:
我是这样解决的,你可以按照这里一步一步来:
MongoDB Steps:
MongoDB步骤:
Download the latest 64-bit MSI version of MongoDBfor Windows.
Run the installer (.msi file)
Add it to your PATHof environment variables. it Should be from:
C:\Program Files\MongoDB\Server\3.0\bin
下载适用于 Windows的最新 64 位 MSI 版本的MongoDB。
运行安装程序(.msi 文件)
将其添加到环境变量的PATH中。它应该来自:
C:\Program Files\MongoDB\Server\3.0\bin
now Create a “\data\db” folder in C:/which is used by mongodbto store all data. You should have this folder:
现在在C:/ 中创建一个“\data\db”文件夹,mongodb使用它来存储所有数据。你应该有这个文件夹:
C:\data\db
C:\数据\数据库
Note: This is the default directory location expected by mongoDB, don't create anywhere else
注意:这是 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.
您应该看到它请求权限(允许),然后侦听端口。完成后,打开另一个命令提示符,让前一个运行服务器。
Type in the new command prompt
输入新的命令提示符
>> mongo
You should see it display the version and connect to a test database.
您应该会看到它显示版本并连接到测试数据库。
This proves successful install!=)
这证明安装成功!=)
回答by Urasquirrel
When you typed in the mongod command, did you also give it a path? This is usually the issue. You don't have to bother with the conf file. simply type
当你输入mongod命令时,你是否也给了它一个路径?这通常是问题。您不必理会 conf 文件。只需输入
mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"
mongod --dbpath="把你的路径放到你想要保存数据库工作区的位置!如果没有这些愚蠢的引号,我也可以添加!"
example: mongod --dbpath=C:/Users/kyles2/Desktop/DEV/mongodb/data
示例:mongod --dbpath=C:/Users/kyles2/Desktop/DEV/mongodb/data
That is my path and don't forget if on windows to flip the slashes forward if you copied it from the or it won't work!
那是我的路径,不要忘记是否在 Windows 上将斜杠向前翻转,如果您是从 复制的,否则它将无法工作!
回答by sonal
I was also faced the same issue with mongodb 2.6.
我也遇到了与 mongodb 2.6 相同的问题。
What solved my problem was I just run mongod --repair
command
解决我的问题是我只是运行mongod --repair
命令
and then start mongod.exe
然后开始 mongod.exe
It's worked for me
它对我有用
回答by morecast
mongodb 2.6.8 on windows7 32bits you only need create a folder c:/data/db execute mongod, and execute mongo
mongodb 2.6.8 on windows7 32bits 你只需要创建一个文件夹 c:/data/db 执行 mongod,然后执行 mongo
回答by Zoran Pandovski
Point to your mongodb instalation e.g C:\Program Files\MongoDB\Serve\bin and run mongod.exe so you can open connection to 127.0.0.1:27017.
指向您的 mongodb 安装,例如 C:\Program Files\MongoDB\Serve\bin 并运行 mongod.exe,以便您可以打开与 127.0.0.1:27017 的连接。
回答by Shaik naseer
just create a folder
只需创建一个文件夹
C:\data\db
Run below commands in command prompt
在命令提示符下运行以下命令
C:\Program Files\MongoDB\Server.4\bin>mongod
Open another command prompt
打开另一个命令提示符
C:\Program Files\MongoDB\Server.4\bin>mongo
回答by Lekan Stephen
The problem is that I missed out 'db' folder for the dbpath in the command:
问题是我在命令中遗漏了 dbpath 的“db”文件夹:
C:\mongodb\bin> mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongodb.log --logappend -rest --install
回答by ?smail Ceylan
Normal case, you need at least 3379 MB of disk space. If you do not have;
正常情况下,您至少需要 3379 MB 的磁盘空间。如果你没有;
mongod.exe --smallfiles
This is not the only requirement. But this may be your problem.
这不是唯一的要求。但这可能是你的问题。
回答by Anticor Mold
If it writes that you had not properly shut down or that mongod.lock is not empty , only delete mongod.lock from C:\data\db\ and it will start.
如果它写到你没有正确关闭或者 mongod.lock 不是空的,只需从 C:\data\db\ 中删除 mongod.lock ,它就会启动。
回答by G.Nader
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:
解决我的问题是创建一个文件 startmongo.conf 将 bind_ip 设置为 127.0.0.1 。之后,我刚刚创建了一个 *.bat 来使用以下内容启动 mongo:
mongod --config c:\mongodb\bin\startmongo.conf