tags:

views:

54

answers:

2

Hi,

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 connecting through the command line?

And what is the difference between port 27017 and 28017?

Should I connect through http or mongodb protocol?

+1  A: 

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.

Josh K
From the guide "mongodb://localhost,localhost:27018,localhost:27019". Why are they using mongodb protocol?
never_had_a_name
@ajsie: No idea, but for the web interface that is incorrect.
Josh K
+4  A: 

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.

Gates VP