How to Connect MongoDB with MongoDB Compass


This article provides a guide for how to connect MongoDB with MongoDB Compass.

How to Connect MongoDB with MongoDB Compass

To connect MongoDB with MongoDB Compass, follow the steps provided:

Configuring a MongoDB to allow remote connection (bindIP)

Note: Please make sure your mongodb service is running and if firewall is installed in your server please make sure you have allowed the 27017 port on the firewall.

Now you need to make changes in /etc/mongod.conf to allow remote connection.

To allow remote connections, you must edit the MongoDB configuration file  /etc/mongod.conf in configuration file look for the bindIp parameter and make sure it is set to either 0.0.0.0 (to allow all IP addresses) or the specific IP address of your server.

For example:-

image

Here we set bindIp: 127.0.0.1, 2.2.2.2 please add IP address of the server on which you’ve installed MongoDB here we have added dummy ip 2.2.2.2.
If you want to allow all ipv4 and ipv6 Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses.

Now restart MongoDB service

Now we can connect MongoDB with MongoDB Compass

Open MongoDB Compass and click on new connection add IP of your server and click on  the Authentication option because the server was secured with authentication enabled you need to enter your administrative MongoDB user’s username, the password.

image

After selecting this you need to select Authentication and then select Username/Password and add administrative MongoDB user’s Username and password.
Administrative MongoDB user password are store at /var/webuzo/mongodb.conf

In the Authentication Database (optional) field you need to add your custom authentication database.

image

Now click on connect.

image

Once the connection is succeeds it will show the list of all the databases.

Conclusion

You now know how to connect MongoDB with MongoDB Compass.

  • mongodb, mongodb compass
  • 0 Users Found This Useful
這篇文章有幫助嗎?

Related Articles

Install MySQL on CentOS 7 Server

This tutorial provides step-by-step instructions for installing MySQL database server on CentOS...

Install MySQL on CentOS 6 Server

This tutorial provides step-by-step instructions for installing MySQL database server on CentOS...

MySQL Server GPG Keys Expired (Workaround)

This article provides a guide for resolving an issue caused by MySQL GPG key expiration. This...

Install MySQL on CentOS 8 Server

This tutorial provides step-by-step instructions for installing MySQL database server on CentOS...

Remove STRICT_TRANS_TABLES in SQL Mode for WHMCS

WHMCS, a billing and support software for the web hosts, may experience a conflict with default...