1

我在远程服务器(debian)中运行了 mongo db,并启用了身份验证。我需要从我的本地机器(windows)使用 UMongo(mongodb 的 UI 工具)连接到它以可视化数据。我没有在服务器机器上打开 mongodb 端口,但是已经建立了一个从我localhost:9999的到mongodb-host:port. 作为 UMongo 中的连接 uri,我给出了

[username]:[password]@localhost:9002
(also tried with [username]:[password]@localhost:9002/dbname)

并尝试连接。它显示数据库但不进行身份验证,它会引发身份验证错误。我已确保提供的凭据是正确的。想知道凭据是否没有通过 ssh 隧道正确传递到 mongodb 服务器。

更新:我在禁用身份验证的情况下重新启动了 mongo 服务器。之后我尝试访问远程 mongo shell。当我尝试使用时mongo --port 9002,它给出了以下错误:

MongoDB shell version: 2.4.4
connecting to: 127.0.0.1:9002/test
Thu Sep 05 22:55:21.107 Socket recv() errno:10054 An existing connection was forcibly
  closed by the remote host. 127.0.0.1:9002
Thu Sep 05 22:55:21.107 SocketException: remote: 127.0.0.1:9002 error: 9001 socket 
exception [1] server [127.0.0.1:9002]
Thu Sep 05 22:55:21.107 DBClientCursor::init call() failed
Thu Sep 05 22:55:21.107 JavaScript execution failed: Error: DBClientBase::findN:   
transport error: 127.0.0.1:9002 ns: admin.$cmd query: { whatsmyuri: 1
} at src/mongo/shell/mongo.js:L114
exception: connect failed

但是当我尝试使用时mongo --port 9002 --nodb,我能够得到 mongo shell。然后我尝试use mydb抛出以下错误:

Thu Sep 05 22:57:43.205 JavaScript execution failed: ReferenceError: db is not defined 
at src/mongo/shell/utils.js:L691

任何帮助将非常感激。

谢谢。

4

0 回答 0