mongodb 通过浏览器连接mongodb?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3595440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:47:32  来源:igfitidea点击:

Connecting to mongodb through the browser?

mongodb

提问by never_had_a_name

Im reading the mongodb guide, but I dont get this:

我正在阅读 mongodb 指南,但我不明白:

mongodb://fred:foobar@localhost

It says I can connect to the mongodb through web browser.

它说我可以通过网络浏览器连接到 mongodb。

I have tried this, but it doesn't work. Safari/Firefox can't recognize the mongodb protocol.

我试过这个,但它不起作用。Safari/Firefox 无法识别 mongodb 协议。

And why should I do it?

我为什么要这样做?

Isn't the mongodb server just for connecting through the command line?

mongodb 服务器不就是为了通过命令行连接吗?

And what is the difference between port 27017 and 28017?

27017和28017端口有什么区别?

Should I connect through http or mongodb protocol?

我应该通过 http 还是 mongodb 协议连接?

回答by Gates VP

When you start mongod (the MongoDB daemon), it starts listening on two ports by default.

当您启动 mongod(MongoDB 守护进程)时,它默认开始侦听两个端口。

  1. 27017: the default port accessed by the various MongoDB drivers.
  2. 28017: a port that handles HTTP requests and provides some general monitoring.
  1. 27017:各种 MongoDB 驱动程序访问的默认端口。
  2. 28017:处理 HTTP 请求并提供一些常规监控的端口。

What you've listed mongodb://fred:foobar@localhostactually represents this: mongodb://fred:foobar@localhost:27017and this is the access protocol for MongoDB drivers.

您列出的内容mongodb://fred:foobar@localhost实际上代表了这一点:mongodb://fred:foobar@localhost:27017这是 MongoDB 驱动程序的访问协议。

The other "thing" you're seeing is port 28017. This is (by default) simply an overview of what's happening with the mongodinstance on that server. Requests made from a web browser to this port will show an HTML output of the server overview.

您看到的另一个“事物”是端口 28017。这(默认情况下)只是mongod对该服务器上的实例所发生情况的概述。从 Web 浏览器向该端口发出的请求将显示服务器概览的 HTML 输出。

If you start mongodwith a different port number (i.e.: 7777), the "monitor" port will always be 1000 higher (i.e.: 8777).

如果您mongod使用不同的端口号(即: 7777)开始,“监视器”端口将始终高出 1000(即: 8777)。

If you want some advanced features like the ability to query via the web browser, you can start mongodwith the --restswitch. You will then be able to run certain queries with a simple http get requestlink text(http://localhost:8777/mydb/mycollection/?filter_a=1).

如果你想要一些先进的功能,如通过网络浏览器能力的查询,就可以开始mongod--rest开关。然后,您将能够使用简单的 http get 请求链接文本( http://localhost:8777/mydb/mycollection/?filter_a=1)运行某些查询。

If you're using language-specific MongoDB drivers (like most people will). Then you'll find that you'll have "connection strings" of the form mongodb://user:pwd@host:port/. These are similar in purpose to the usual connection strings you're used to for other Database products.

如果您使用的是特定于语言的 MongoDB 驱动程序(就像大多数人一样)。然后您会发现您将拥有形式为 的“连接字符串” mongodb://user:pwd@host:port/。它们的用途类似于您用于其他数据库产品的常用连接字符串。

回答by Josh K

Increment by one thousand (28017), and use HTTP, not mongodb.

增加一千(28017),并使用HTTP,而不是mongodb。

Note that this will "connect" you to the mongodb process, but it's not like phpMyAdmin or anything.

请注意,这会将您“连接”到 mongodb 进程,但它不像 phpMyAdmin 或其他任何东西。