In this exercise, you’ll configure MongoDB Atlas to connect to the cluster you created in Exercise 1.
For this, you will need the IP address of the device that will connect to the service.
If you plan to connect to MongoDB Atlas on the same device where you’re setting up the service, MongoDB Atlas can find the local IP address automatically.
As part of this exercise, you’ll also set up an administrator account for accessing the cluster. You’ll then generate a connection string or Uniform Resource Identifier (URI) based on this account. You’ll be able to use the connection string in Studio 3T to access MongoDB Atlas.
How to connect
1. In the Cluster1 section of the Clusters page, click the CONNECT button in the left pane.
The Connect to Cluster1 dialog box appears, showing the two steps you must take to configure your connection.
2. For security reasons, MongoDB Atlas blocks all outside connections by default. In order to connect, you must first whitelist your IP address. In the Step 1 section, do one of the following:
- If you plan to connect from the computer you’re currently using, click Add Your Current IP Address and then click Add IP Address.
- If you plan to connect from a different computer, click Add a Different IP Address, type the IP address, and then click Add IP Address. You can edit the IP address, add IP addresses, or delete them at any time in case you change devices.
3. In the Step 2 section, type admin in the Username text box (or whatever name you want to use), and then type a password in the Password text box.
To make it easier to connect to MongoDB Atlas from Studio 3T, your password should include only alphanumeric characters, that is, letters and numbers only with no special characters.
If you use special characters, you will need to encode them when creating a connection string for accessing the MongoDB service.
4. Click the Create MongoDB User button.
5. The next task is to generate the connection string or Uniform Resource Identifier (URI).
To start this process, click the Choose a connection method button. The Connect to Cluster0 dialog box reappears, providing a different set of options.
6. Click Connect Your Application.
You’ll again be presented with two steps.
7. In the Step 1 section, select Java from the DRIVER drop-down list, and select 3.6 or later from the VERSION drop-down list.
These are the settings that Studio 3T requires to connect to MongoDB Atlas.
When you select the driver and version, the service automatically updates the connection string in the Step 2 section.