How do i access the http interface of mongodb?

Skip to content

This is a complimentary post following the installation of MongoDB, as you probably now, MongoDB comes with a web interface, easy to visualize what is going on with your MongoDB databases.
To access this web interface, you just need to use the following address.

http://localhost:28017

However, this is not enabled by default. In case you do not have started MongoDB with the web interface enabled you may need to restart the service adding the parameter –httpinterface.

With MongoDB running, open a terminal window and start the MongoDB Shell, just by typing:

$ mongo

Then, use the following commands to shutdown the server.

$ use admin
$ db.shutdownServer()

You are going to see a message similar to this.

How do i access the http interface of mongodb?

Now, that the server is down you just need to start using the –httpinterface parameter.

$ mongod --httpinterface

If everything goes right, you should be able to access the http://localhost:28017 and see something like this.

How do i access the http interface of mongodb?

Thank you for visiting. 🙂
Let’s Mongo Together.

How do i access the http interface of mongodb?

Definition of MongoDB Web Interface

MongoDB web interface is a tool used to administrate our database server via the web browser, there are multiple web interface tools available in MongoDB. There is multiple features of the web interface in MongoDB like we can create database and collection by using the web interface. We can also use the web interface GUI tool to monitor the MongoDB database server, there are multiple MongoDB web interface GUI tools available like Studio 3T, Robo 3T, NoSQL booster, DB Schema, MongoDB monitoring tools, and NoSQL manager. This tool is used to improve the productivity of DBA and development tasks.

Syntax

Below is the syntax of web interface in MongoDB.

1) Connect to the database cluster using MongoDB compass –

mongodb+srv://database_username:<user_password>@hostname/database_name

2) Connect to the database cluster using MongoDB shell –

mongo "mongodb+srv://hostname/database_name" –database_username <name of user>

Parameters:

1) Mongodb – This parameter is used to connect the MongoDB database cluster using the MongoDB compass. We can connect MongoDB compass by using the mongodb command, we can also pass the username, hostname, and password at the time of connecting to the database server.
2) Database username – This is defined as a username that was used to connect the database server. We need to give specified privileges on the database to the user for performing the task.
3) User password – This is defined as the user password which was used to authenticate a user with the database server. We need to specify the correct username password for connecting to the database server.
4) Hostname – This is defined as the name of the user who was used to connect to the database server. We can use either hostname or database server IP for connecting to the database server.
5) Database name – This is defined as the name of the database which was used with the connection string to connect the database server. I suppose we have used the database name at the time of connection string it will connect to the specified database.
6) Mongo – This is a command in MongoDB which was used to connect to the database server. We can connect to the database server by using the mongo command.

How does the web interface work in MongoDB?

  • We can connect the MongoDB database server by using the web interface, there are multiple web interface tools available to connect the database server.
  • To connect the MongoDB compass web interface we need to encode our database user password, without encoding it will not accept the database password.
  • If we have provided a password in plain text format then it will not accept the password. It will show an error.
  • The below example shows that we need to encode a password before using this into the connection string using MongoDB compass.
  • In the below example, we have used a connection string for connecting to the database server. We have used username as dbuser and password as Mongodb@123.
  • But we have used this password in plain text format so it will show the error at the time of login into the database server.

Code:

mongodb+srv://dbuser:Mongodb@/test

How do i access the http interface of mongodb?

Figure – we need to encode password before using this into the connection string using MongoDB compass.

  • We need to convert the following characters from plain text to encoding format at the time of using this password in MongoDB compass.

: / ? # [ ] @

  • If suppose our password contains any of the above letters then we need to convert the same into encoding format.
  • For example, if suppose our database user password is “Mongodb@123” the encoded password is “Mongodb%40123”.
  • After connecting to the MongoDB compass web interface we can create a database and collection using the GUI interface.
  • There are multiple tools available in MongoDB to connect the MongoDB database server.
  • MongoDB compass is the real-time web interface for the database user, using MongoDB compass we can real-time access our database server.
  • Using MongoDB atlas cluster we can also connect from the MongoDB shell using the mongo command.

Examples

The below example shows the web interface in MongoDB.

1) MongoDB web interface connects the MongoDB atlas cluster via MongoDB shell

  • The below example shows that MongoDB web interface connects the MongoDB atlas cluster via MongoDB shell.
  • We have connected to the “cluster0.xttyr.mongodb.net” host by using the user as dbuser. We can see that we are connected to the “cluster0.xttyr.mongodb.net” host which was hosted on the MongoDB atlas cluster.

Code:

mongo "mongodb+srv://cluster0.xttyr.mongodb.net/myFirstDatabase" --username dbuser
show dbs
use local
show collections

How do i access the http interface of mongodb?

Figure – Example of MongoDB web interface connect to the MongoDB atlas cluster via MongoDB shell.

In the above example, we have connected to the database cluster after connecting to the cluster we have to use a local database and display the collections from a local database.

2) MongoDB web interface connects to the database cluster via MongoDB compass

The below example shows that MongoDB web interface connects to the database cluster via MongoDB compass.

We have connected to the “cluster0.xttyr.mongodb.net” host by using the user as dbuser and the password as “Mongodb@123”. We have encoded the given password before use into the MongoDB compass.

We can see that encode format of “Mongodb@123” password is “Mongodb%40123”.

Code:

How do i access the http interface of mongodb?

mongodb+srv://dbuser:Mongodb%40/test

Figure – Example of MongoDB web interface connect to the database cluster via MongoDB compass.

3) Create the database in MongoDB web interface by using MongoDB compass

The below example shows that create the database and collection in MongoDB web interface by using MongoDB compass.

  • To create the database first click on create a database, after clicking on create database need to give the database name and collection name.
  • After giving a specified database and collection name click on create a database. After clicking create a database we can see that the specified database is created and we can see the same in the dashboard.
  • We have created a database name as MongoDB and a collection name as collection_test.

Code:

MongoDB Dashboard -> Create database -> Give database name and collection name -> click on create database.

How do i access the http interface of mongodb?

How do i access the http interface of mongodb?

Figure – Example of creating the database and collection in MongoDB web interface by using MongoDB compass.

Conclusion

MongoDB compass is the real-time web interface tool used in MongoDB to monitor the database and application. We can create the database and collection by using MongoDB compass. We can connect the MongoDB atlas cluster by using the MongoDB shell and mongo command.

This is a guide to MongoDB Web Interface. Here we discuss the Introduction, How does the web interface work in MongoDB? and examples respectively. You may also have a look at the following articles to learn more –

  1. MongoDB findOne()
  2. MongoDB group by
  3. MongoDB Database
  4. MongoDB sort()

How do I access MongoDB HTTP?

By default, MongoDB starts at port 27017. But you can access it in a web browser not at that port, rather, at a port number 1000 more than the port at which MongoDB is started. So if you point your browser to http://localhost:28017, you can see MongoDB web interface.

Does MongoDB have a web interface?

MongoDB web interface is a tool used to administrate our database server via the web browser, there are multiple web interface tools available in MongoDB. There is multiple features of the web interface in MongoDB like we can create database and collection by using the web interface.

How do I view MongoDB database?

In MongoDB, you can use the show dbs command to list all databases on a MongoDB server. This will show you the database name, as well as the size of the database in gigabytes. You can select any database using the use statement and work on it.

Does MongoDB have an API?

The MongoDB Query API is purpose-built to handle data of any structure. Quickly query, transform, and analyze data as your schema evolves.