Connecting to MongoDB Atlas

Studio enables you to use the database connectors to connect to your databases like Elasticsearch, MongoDB, CouchDB, DynamoDB, Cloud DataStore, Firebase, and so on.

Studio provides the MongoDB Connector to connect to both managed and self-hosted MongoDB databases including MongoDB Atlas and AWS DocumentDB. Studio supports MongoDB’s standard connection format (mongo://) as well as the new seed list connection format (mongodb+srv://). So if you are using a managed offering such as MongoDB Atlas, the seed list connection format may be preferred.

Let us consider connecting to the MongoDB Atlas which is a multi-cloud database service from MongoDB. It simplifies deploying and managing databases to build high-performing global applications on your cloud providers.

  • To build on top of your MongoDB Atlas you need to first login to your Atlas account with your Google Credentials into your MongoDB Atlas account to get the connection string that would help you to connect to the Cluster.

  • After you log in you would be taken to the Clusters overview.

  • Click Connect and choose the Connection Method.

  • Under Setup connection security, you can whitelist the IP Address to be used for the Atlas connections. If it is not whitelisted, click Add your Current IP Address if you want to whitelist the current one or add the specific one to be whitelisted.

Note: Make sure that the DronaHQ IP addresses mentioned under MongoDB Connector > WhiteList IP are added to the whitelist.

strong text
Optionally you can go to Security > Network Access and click Add IP Address, to add the specific IP address to the project’s IP Access List. For further detailed information on Configuring Whitelisting Entries refer to the article from MongoDB.

Database user Access

In the connection string, you need to add the users who would need access to the database.

  • Under Your Project > Security menu, select Database Access.

  • From here add a new database user or if you already have created the user then click Edit under Actions to check the Password authentication details and the Database user privileges. Make the necessary changes to the user privileges depending upon the user. If you want to add a new password for the specific users, then you can add a New Password under Password Authentication or Autogenerate Secure Password.

  • You can also provide specific privileges by selecting roles and databases associated with the role. For more details refer to the MongoDB documentation here. You can also restrict access to some of the Clusters and the resources this user can access. By default, all resources in this project are accessible.

Configure the connector

The most important part of the process is to provide Connector configuration details to configure the MongoDB Atlast connection.

You can either provide the Connection string or provide the respective parameters.

In this case, note that to connect to the MongoDB database/dataset you would need a few parameters or fields. Here, we will be taking a sample public MySQL database sample_airbnb. The connection parameters that are required are Host and database name.

You can also enable further action to Connect using SSL, Enable SSH Tunneling, and Whitelisting IP.

Note: Check the respective username and retype the password

Once all parameters are added and verified then click Test Connection.

If the connection is successful, Save.

You can then follow the same procedure as followed here to add query and use your data within your Apps.