通过浏览器连接到mongodb吗? [英] Connecting to mongodb through the browser?

查看:526
本文介绍了通过浏览器连接到mongodb吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

mongodb://fred:foobar@localhost

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

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

我已经尝试过了,但是没有用. Safari/Firefox无法识别mongodb协议.

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

那我为什么要这么做?

mongodb服务器不是仅用于通过命令行连接吗?

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

端口27017和28017有什么区别?

And what is the difference between port 27017 and 28017?

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

Should I connect through http or mongodb protocol?

推荐答案

启动mongod(MongoDB守护程序)时,默认情况下它将开始在两个端口上侦听.

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

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

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

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

您看到的另一个事物"是端口28017.(默认情况下)这只是该服务器上mongod实例发生的情况的概述.通过网络浏览器对此端口发出的请求将显示服务器概述的HTML输出.

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

如果以不同的端口号( ie:7777 )开始mongod,则"monitor"端口将始终高出1000( ie:8777 ).

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

如果需要一些高级功能,例如通过Web浏览器查询的功能,可以使用--rest开关启动mongod.然后,您将能够通过简单的http get请求运行某些查询链接文本 (http://localhost:8777/mydb/mycollection/?filter_a=1).

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

如果您使用的是特定于语言的MongoDB驱动程序(就像大多数人一样).然后,您将发现具有格式为mongodb://user:pwd@host:port/的连接字符串".这些目的与您用于其他数据库产品的常用连接字符串相似.

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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆