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.
About this Task
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.
Before you Begin
To save a connection to a MongoDB Atlas cluster, you must be logged in with MongoDB Atlas.
Steps
Database Connection String
Relational Migrator supports all MongoDB connection string options except appName
. It
overrides appName
when connecting to your MongoDB deployment.
Atlas Connection URI
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
On-Premises Connection URI
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
Using X.509 Authentication
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 | ||
---|---|---|---|
| |||
| |||
Path to the IMPORTANT: Unlike other MongoDB products, Relational Migrator
requires a path to a
| |||
Password to decrypt the | |||
Path to the local |
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
Connect to MongoDB
To save a new connection from the Connections page:
Enter the MongoDB connection string
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.
If it isn't included in the connection string, enter the Database to connect to.
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.