开发者

Connecting to mongodb through the browser?

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

mongodb://fred:foobar@localhost

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

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

And why should I do it?

Isn't the mongodb server just for connect开发者_开发知识库ing through the command line?

And what is the difference between port 27017 and 28017?

Should I connect through http or mongodb protocol?


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

  1. 27017: the default port accessed by the various MongoDB drivers.
  2. 28017: a port that handles HTTP requests and provides some general monitoring.

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.

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.

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

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).

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.


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜