Connecting to MongoDB Atlas with MongoDB Drivers



MongoDB Atlas is a cloud-hosted version of MongoDB (DBaaS), managed and maintained by MongoDB Inc. It operates exactly the same as a local MongoDB server, but as a DBaaS, you have access to your data from anywhere. The CData Drivers for MongoDB natively support connecting to a MongoDB Atlas instance, so you have standards-based drivers for working with your data available right now.

This article walks through mapping the URI connection string properties from a MongoDB Atlas instance to the connection properties for the CData Software Drivers for MongoDB.


Connecting to MongoDB Atlas



In order to connect to your MongoDB Atlas instance, you need the connection properties for the instance, which can be found in the URI connection string for your cluster(s). To find your URI connection string, log in to your MongoDB Atlas instance and from the Clusters view, click CONNECT for the cluster. You can map the values from the URI connection string to the appropriate connection properties for the CData Driver for MongoDB (see the image below).

The only other connection property that you need to set is Slave OK which needs to be set to true. A sample connection string (based on the above URI connection string) for the CData ADO.NET Provider for MongoDB follows:

string connString = "User=admin;Password=<PASSWORD>;Server=atlas-host1;Port=27017;" +
  "Database=<DATABASE>;AuthDatabase=admin;AuthMechanism=SCRAM-SHA-1;" +
  "ReplicaSet=cluster0-shard-00-01-u49p2.mongodb.net:27017,cluster0-shard-00-02-u49p2.mongodb.net:27017;" + 
  "UseSSL=true;SlaveOK=true;";

Free Trial



With the properties mapped, you can quickly connect to your MongoDB Atlas instance using any of the MongoDB Drivers. Download a free trial of any of the drivers to start working with your MongoDB Atlas data in the BI, reporting, ETL, and custom tools that you are already using.