远程连接mongodb - 无法连接

问题描述 投票:0回答:1

我正在尝试远程连接到 mongodb。 mongodb 服务器在我的桌面上运行,需要通过可以在任何设备上运行的 JavaScript 应用程序访问。

到目前为止我已采取的步骤:

#1 Openned port 27017 for listening on in the operating system

#2 Edited the config file commenting out #bindIp: 0.0.0.0 and replacing with the desktop 
static ip #bindIp: 192.168.1.xxx and added security: authorization: 'enabled'

#3 Created an admin user in the admin database on mongodb use admin 
db.createUser({ user: 'name', pwd: 'password', roles: [{ role: 'userAdminAnyDatabase', 
db:'admin'}]

#4 Tested the above login locally on the desktop and access is granted

#5 Restarted the mongodb service

#6 The connection string is use "mongodb://name:[email protected]"

但是我仍然无法远程连接到数据库。我到处寻找帮助并阅读文档,有人可以指出我做错了什么,或者提供一个资源链接,逐步指导如何远程连接。这将非常感激。

mongodb server database-connection
1个回答
0
投票

用途:

bindIp: 0.0.0.0

如果遇到任何权限问题,请使用

authSource=admin
,如下所示:

网址:

mongodb://admin:[email protected]:27017/Database?authSource=admin

希望这可以帮助你。

© www.soinside.com 2019 - 2024. All rights reserved.