Docs Menu
Docs Home
/
Relational Migrator
/

MongoDB Database Connection Strings

On this page

  • About this Task
  • Atlas
  • On-Premises
  • Results

Note

URIs in Relational Migrator are optional. You can use the connection string forms to enter your connection details instead of manually providing URIs.

To start a migration job, Relational Migrator must connect to your MongoDB database. Relational Migrator requires a username and password which has readWrite access in the target database. This page describes the procedure to make an authenticated user account and the Uniform Resource Identifier (URI) formats for defining connections to your target MongoDB database.

  • Relational Migrator supports all connection string options except appName. Relational Migrator overrides the appName connection string option when connecting to your MongoDB deployment. For details on MongoDB connection string options, see Connection Strings.

  • Relational Migrator can use both Atlas and on-premises URIs. This page provides separate instructions for each deployment type.

To provision user accounts in Atlas you need to be logged in to the Atlas GUI.

  1. In the Security section of the left navigation, click Database Access.

  2. Click Add New Database User.

  3. In the Authentication Method section of the Add New Database User modal window, select the box labeled Password.

  4. Under Password Authentication, enter the username migrator-service for the new user in the top text field.

  5. Enter the password password for the new user in the lower text field.

  6. Under Database User Privileges, click Built-in Role.

  7. Select Read and write to any database.

  8. Click Add User.

Using the previously created account credentials, format the connection URI for the target database. In this case MongoEnterprises.

mongodb+srv://migrator-service:password@sandbox.xxxxx.mongodb.net/MongoEnterprises

In this example, use mongosh to provision a user account that connects to the MongoEnterprises database.

This examples assume your deployment is running on localhost and the default port of 27017.

When connecting to your deployment, your user account requires the createRole permission in both the admin and MongoEnterprises databases. Copy the following code with your admin credentials into a terminal to connect to your deployment with mongosh.

mongosh "mongodb://myadminuser:myadminpassword@localhost:27017/admin"

For details on mongosh connections see : Connecting to your MongoDB Deployment.

In mongosh, run the following command to create a user in the admin database:

use admin
db.createUser(
{ user: "migrator-service",
pwd: "password",
roles:[{role: "readWrite" , db:"MongoEnterprises"}]
}
)

Create the same user in the user in the MongoEnterprises database:

use MongoEnterprises
db.createUser(
{ user: "migrator-service",
pwd: "password",
roles:[{role: "readWrite" , db:"MongoEnterprises"}]
}
)

These commands:

  • Create a new user migrator-service with the password password in the admin and MongoEnterprises databases.

  • Apply the readWrite system role to the MongoEnterprises database for the user migrator-service.

Using the previously created account credentials, format the connection URI for the target database. In this case MongoEnterprises.

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

The MongoDB connection URI is optionally specified as part of the process for creating a Relational Migrator project or when creating a sync job.

← Connection Strings