window上mongodb错误:No connection could be made

今天在慕课网(很不错的一个IT技术免费网站)上学习nodeJS开发电影网站,其中使用到了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.

...

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

在http://stackoverflow.com/questions/23726684/mongodb-on-a-windows-7-machine-no-connection-could-be-made中找到了解决办法,如下:



2 down vote

I got same error and fixed it by:

1) mkdir c:\data

2) cd data

3) mongod -dbpath .

4) Now in another command window i was able to connect from my client using "mongo" command.

试了一下,使用两个命令行,一个用于接收连接,一个用于发送连接。问题是解决了,但是还是没发现问题的本质原因,如有知道了,请给我留言,谢谢各位。


你可能感兴趣的:(exception,数据库,windows,command)