简体   繁体   English

Mongo使用asp.net连接问题

[英]Mongo connect problem using asp.net

I wrote these lines in My Application start event: 我在“我的应用程序”开始事件中写了以下几行:

    var mongo = new Mongo();
    mongo.Connect();
    var blog = mongo.GetDatabase("Blog");
    mongo.Disconnect();

but on this line: mongo.Connect(); 但在这一行: mongo.Connect(); it gave me this error: 它给了我这个错误:

No connection could be made because the target machine actively refused it 127.0.0.1:27017 无法建立连接,因为目标计算机主动拒绝它127.0.0.1:27017

I am a beginner using Mongodb and i am just try to make sample code to see it's power. 我是使用Mongodb的初学者,我只是尝试制作示例代码以查看其功能。
So i have no idea how to solve this problem. 所以我不知道如何解决这个问题。

I am using VS2008 with MongoDB.Driver on Windows7. 我在Windows7上将VS2008与MongoDB.Driver结合使用。

UPDATE UPDATE

I got also that the same problem is happening while trying this tutorial: http://www.mongodb.org/display/DOCS/Tutorial#Tutorial-GettingADatabaseConnection using the shell. 在尝试本教程时,我也得到了同样的问题: http : //www.mongodb.org/display/DOCS/Tutorial#Tutorial-GettingADatabaseConnection使用shell。

For this problem what you can do is just check your dbpath in mongod.cfg file in your mongo folder. 对于此问题,您可以做的只是检查mongo文件夹中mongod.cfg文件中的dbpath

It should be the exact path of your data folder like for example dbpath=e:\\data\\db . 它应该是数据文件夹的确切路径,例如dbpath=e:\\data\\db

i found the problem, the problem that mongodb is pointing to the default database directory c:\\data\\db 我发现了问题,mongodb指向默认数据库目录c:\\ data \\ db的问题

now i will try to get how to change this directory to another one. 现在,我将尝试获取如何将此目录更改为另一个目录。

http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo

When this problem occurs, you must delete the mongod.lock file. 发生此问题时,您必须删除mongod.lock文件。 MongoDB then immediately creates a new lock, and the service becomes available again. 然后,MongoDB立即创建一个新的锁,该服务再次可用。

BTW, in order to work with MongoDB more easily, check out MongoVUE at http://www.mongovue.com . 顺便说一句,为了更轻松地使用MongoDB,请访问http://www.mongovue.com上的 MongoVUE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM