Using Robo3T to connect to IBM Cloud Databases for MongoDB
We have a lot of customers who enjoy using their favorite database management tools and want to use them to manage their databases in the cloud. In this article, we’ll show you how to connect to IBM Cloud Databases for MongoDB using Robo3T (formerly Robomongo), a popular GUI for managing your MongoDB deployments.
Robo3T (formerly Robomongo) is a great GUI for managing and querying MongoDB. We’ve been getting a lot of questions about how to connect to IBM Cloud Databases for MongoDB using the tool so we’re going to show you an easy way.
We’ll start off by provisioning a Databases for MongoDB deployment and then create the credentials that we’ll use to connect to Robo3T. After that, we’ll use those credentials to set up a connection using Robo3T’s GUI interface to make a successful connection to your MongoDB deployment.
Creating the Databases for MongoDB deployment
In this example, we’ll provision a Databases for MongoDB deployment using the IBM Cloud CLI. To create a database, you’ll need to log in first. If you’re using a federated identity, you’ll use:
ibmcloud login --sso
After logging in, create the database with:
ibmcloud resource service-instance-create <your_db_name> databases-for-mongodb standard us-south
ibmcloud resource service-instance-create ICD-MongoDB databases-for-mongodb standard us-south
Getting the Database credentials
Once the database is done provisioning, you can get the credentials using the
cloud-databases plugin. Install that using the following command:
ibmcloud plugin install cloud-databases
Now you’ll be able to access your database credentials with the
ibmcloud cdb command. Using that command, let’s get your Databases for MongoDB credentials:
ibmcloud cdb cxn ICD-MongoDB
This will show you your connection strings like this:
MongoDB mongodb://admin:$PASSWORD@aaa-aaa-aaa-aaa-aaa-0.aaa.databases.appdomain.cloud:32508/ibmclouddb?authSource=admin mongodb://admin:$PASSWORD@aaa-aaa-aaa-aaa-aaa-1.aaaa.databases.appdomain.cloud:32508/ibmclouddb?authSource=admin CLI mongo -u admin -p $PASSWORD --ssl --sslCAFile aaa-aaa-aaa-aaa-aaa --authenticationDatabase admin --host replset/aaa-aaa-aaa-aaa-aaa-0.aaa.databases.appdomain.cloud:32508,aaa-aaa-aaa-aaa-aaa-1.aaa.databases.appdomain.cloud:32508
You’ll need both connection strings that start with
mongodb://... to make a successful connection as a replica set. We only need the host names and the ports. Note that the replica set name is
replset, which is the case for all Databases for MongoDB connections.
The next step is to set the
admin password. We’ll set the
admin password to
mypassword for this example:
ibmcloud cdb deployment-user-password ICD-MongoDB admin mypassword
You’ll also need to decode the CA certificate that your databases need for authentication. To decode it, run the following command then make sure to copy the decoded certificate and save it to a file on your system:
ibmcloud cdb cacert ICD-MongoDB
Connecting to Robo3T
You can now use your credentials to connect to Robo3T. When you start Robo3T, you’ll be presented with a screen to create a connection. Click on the Create button at the top-left corner.
A window will pop with a few tabs that you will need to add your credentials to so that you can log in. The first is the Connection tab. For Type, you need to select “Replica Set.” You can provide any Name you want for the connection. Next, for Members, you’ll need to add your Databases for MongoDB hosts with their ports that you got earlier. The Set Name should be
replset, as I mentioned above.
Now, click on the Authentication tab. Here, you’ll need to click on the Perform authentication box. The Database you’ll authenticate to is “admin.” Then, insert your admin username and password in the boxes below that. Keep the Auth mechanism set to the default.
The final step is to click on the SSL tab. Click on the Use SSL protocol box. Then, click on the box … next to CA Certificate. Select the file that contains your decoded and saved CA certificate.
To check to see if your connection is successful, click on the Authentication tab again, and at the bottom of that window, you’ll see the Test button. Click that button and you’ll see a pop-up window appear indicating that Robo3T is trying to connect. If it’s successful, you’ll receive two green check marks that you’re “Authorized on admin database as admin.” Once that’s done, click Save at the bottom of the window.
This will take you back to the main screen where you set up the connection.
Now, click on Connect at the bottom of that screen and you will see your Databases for MongoDB collections appear on the left side of the Robo3T tool.
Start using Databases for MongoDB
Provisioning a Databases for MongoDB deployment, getting the credentials, and making a successful connection to Robo3T is straightforward and easy to do. All you need to do now is start using your database.