Docs Menu
Docs Home
/
Relational Migrator
/

Connect to MongoDB

On this page

  • About this Task
  • Before you Begin
  • Steps
  • Database Connection String
  • Connect to MongoDB

This page shows how to save a new MongoDB connection from the Connections tab. You can use a saved connection for any task that requires connecting to a database.

Note

Relational Migrator does not support MongoDB to MongoDB migrations. For information on supported databases, see Supported Databases and Versions.

For information on migrating between MongoDB clusters, see MongoDB Cluster-to-Cluster Sync.

To save a MongoDB connection in Relational Migrator, you must:

  • Identify your database connection string or database information.

  • Connect to MongoDB.

Important

To plan your migration and map your relational schema to a MongoDB schema, you must connect using an account with the correct read permissions.

To migrate data, you must connect to MongoDB using a service account with the readWrite role. For information about creating a MongoDB user with the required permisions, see Create a Relational Migrator User in MongoDB.

To save a connection to a MongoDB Atlas cluster, you must be logged in with MongoDB Atlas.

Relational Migrator supports all MongoDB connection string options except appName. It overrides appName when connecting to your MongoDB deployment.

mongodb+srv://username:password@clusterurl.mongodb.net/database

For example, to use an account named migrator-service with password hunter2 to connect to the MongoEnterprises database:

mongodb+srv://migrator-service:hunter2@cluster1.abc123.mongodb.net/MongoEnterprises
mongodb://username:password@host:port/database

For example, to use an account named migrator-service with password hunter2 to connect to the MongoEnterprises database:

mongodb://migrator-service:hunter2@localhost:27017/MongoEnterprises

To connect to MongoDB using X.509 authentication, omit a username and password. Instead, specify the on-premises host and port or the Atlas cluster URL and set the following options:

<on-premises host:port or clusterurl.mongodb.net>?authSource=$external&authMechanism=MONGODB-X509&tlsCertificateKeyFile=</path/to/cert/client.p12>&tlsCertificateKeyFilePassword=<certpassword>
Option
Value

$external

MONGODB-X509

Path to the .p12 file that contains the certificate and key to present to the mongod or mongos instance.

IMPORTANT: Unlike other MongoDB products, Relational Migrator requires a path to a .p12 file, not a .pem file. If your certificate is saved as a .pem file, you can convert it using a tool like OpenSSL's PKCS12 command:

openssl pkcs12 -export -inkey cert_key_pem.txt -in cert_key.pem -out
cert_key.p12

Password to decrypt the .p12 file.

Path to the local .pem file that contains the root certificate chain from the Certificate Authority. Required only if the MongoDB instance has a TLS/SSL setup with its own public key infrastructure.

For example, to connect to the MongoEnterprises database on cluster1.abc123.mongodb.net, using the certificate file /etc/ssl/caToValidateServerCertificates.p12 with the password verysecure:

mongodb+srv://cluster1.abc123.mongodb.net/MongoEnterprises?authSource=$external&authMechanism=MONGODB-X509&tlsCertificateKeyFile=/etc/ssl/caToValidateServerCertificates.p12&tlsCertificateKeyFilePassword=verysecure

To save a new connection from the Connections page:

1

In the list of MongoDB connections, click + Add connection.

2
  1. In MongoDB connection string (URI), enter your MongoDB URI.

    If you're using X.509 authentication, Relational Migrator verifies the connection string syntax and the certificate file format.

  2. If it isn't included in the connection string, enter the Database to connect to.

  3. If they aren't included in the connection string and you aren't using X.509 authentication, enter the Username and Password of your Relational Migrator MongoDB user.

    Checking Save password saves the password securely on your machine, so you don't have to enter the Username and Password again when using the saved connection.

If you leave the Database, Username, or Password blank, Relational Migrator uses the values from the URI.

3

Relational Migrator attempts to authenticate and connect to the database.

4

The saved connection is available for use in all jobs and projects.

Back

Configure DB2