MongoDB Atlas is a hosted solution for accessing your MongoDB data in the cloud. Because MongoDB Atlas is a clustered implementation, you configure the driver to connect through the domain, instead of directly to a server. At connection, the driver performs a DNS lookup to discover the member nodes, then connects to an available node in the cluster.

Note: In addition to MongoDB Atlas, you can connect to other clustered environments by specifying the domain name using the Host Name (HostName) option. However, other settings for that data source, such as authentication, are likely to differ from those described in this topic. Note that the Enable DNS Lookup (EnableDNSLookup) option must be set to 1 (the default) to connect to a clustered environment.

To connect to a MongoDB Atlas cluster:

  • Set Host Name (HostName) to specify the domain name of your MongoDB Atlas cluster to which you want to connect. For example, myaltas.mongodb.net.
  • Optionally, set Database Name (DatabaseName) to specify the name of the database to which you want to connect. This value is used as the default qualifier for unqualified table names in SQL queries.
  • Set PortNumber (PortNumber) to specify the port number of the server listener. The default is 27017.
  • Set Authentication Method (AuthenticationMethod) to 0 (the default).
  • Set Encryption Method (EncryptionMethod) to 1 (SSL).
  • Set User (User) to specify the user name that is used to connect to the MongoDB database. For example, jsmith.
  • Set Password (Password) to specify the password used to connect to your MongoDB database.
  • Optionally, set the Authentication Database (AuthenticationDatabase) option to specify the database in which your user ID was created. This value allows you to explicitly select a set of credentials and permissions when the same user ID was created in multiple databases on the server.
    Note: We recommend specifying a value for the Authentication Database to ensure the correct permissions are used for your connection. If you do not specify a value for this option, the driver attempts to use your user ID with the database specified by the Database Name option. If your user ID was not created in the specified database, the driver will attempt to connect to the Admin database using your user ID and password.

The following examples include the option attributes required for connecting to a MongoDB Atlas cluster.

Connection string

DRIVER=DataDirect 8.1 MongoDB;AuthenticationDatabase=mydb2;DatabaseName=mydb;
  EncryptionMethod=1;HostName=//myaltas.mongodb.net;PortNumber=27017;User=jsmith;
  Password=secret;

odbc.ini

[MongoDB]
Driver=ODBCHOME/lib/ivmongodb81.so
...
Description=DataDirect 8.1 MongoDB
...
AuthenticationDatabase=mydb2
...
DatabaseName=mydb
...
EncryptionMethod=1
...
HostName=//myaltas.mongodb.net
...
PortNumber=27017
...
User=jsmith
...
Password=secret
...