MongoDb服务器拒绝远程连接

时间:2017-10-30 20:52:57

标签: c# mongodb

我在Ubuntu上安装了MongoDb Community,并希望从我的其他服务器连接到它。

/etc/mongod.conf文件中,当我评论这些行时,它可以工作:

# security:
#  authorization: 'enabled'

但是当我取消注释时,我收到了这个错误:

No connection could be made because the target machine actively refused it

在两种情况下都会注释bindIp

#  bindIp: 127.0.0.1

安装后,我以这种方式创建了一个用户:

use DataDb

db.createUser({
    user: 'u1',
    pwd: 'secretPassword',
    roles: [{ role: 'readWrite', db:'DataDb'}]
})

我的连接字符串是这样的:

var client = new MongoClient("mongodb://u1:pass@xxx.xx.xxx.xxx:27017/DataDb");

有什么问题?感谢。

0 个答案:

没有答案