# Configuring MongoDB workspace data connections

During workspace creation, under **Connection Type**, select **MongoDB**.

## Connecting to the source database <a href="#mongodb-data-connection-source" id="mongodb-data-connection-source"></a>

The **Source Settings** section contains the connection information for the source database.

### Providing the connection details <a href="#mongodb-data-connection-source-connection" id="mongodb-data-connection-source-connection"></a>

To provide the connection details, you can either populate the connection fields or use a connection string.

#### Populating the connection fields <a href="#mongodb-data-connection-source-details-fields" id="mongodb-data-connection-source-details-fields"></a>

By default, **Use connection string** is off, and you provide the connection values in the individual fields:

1. In the **Server** field, provide the host name or IP address of the MongoDB instance.
2. In the **Database** field, provide the name of the MongoDB database.
3. In the **Port** field, provide the port number to connect to the server host.
4. In the **Username** field, provide the username of a MongoDB user in your authentication database.
5. For **Password**, you can either specify the password manually or, if secrets managers are available, you can [select a secret name from a secrets manager](/app/workspace/workspace-configuration-settings/secrets-manager/selecting-a-secrets-manager-secret.md).
6. In the **Authentication Database**, provide the database where the MongoDB user that you authenticate with is stored. The default is often the admin database.
7. To test the connection to the source database, click **Test Source Connection**.

#### Using a connection string <a href="#mongodb-data-connection-source-details-connection-string" id="mongodb-data-connection-source-details-connection-string"></a>

To use a connection string to connect to the source database:

1. Toggle **Use Connection String** to the on position.
2. In the **Connection String** field, provide a [MongoDB connection string](https://docs.mongodb.com/manual/reference/connection-string/).\
   \
   For the password, use `<password>` as a placeholder value.
3. In the **Database** field, provide the name of the MongoDB database.
4. In the **Password** field, provide the password to use to replace `<password>`.
5. To provide the user password to replace  `<password>`, you can either specify the password manually, or you can [select a secret name from a secrets manager](/app/workspace/workspace-configuration-settings/secrets-manager/selecting-a-secrets-manager-secret.md).&#x20;
6. To test the connection to the source database, click **Test Source Connection**.

### Using a DNS seed list <a href="#mongodb-source-dns-seed-list" id="mongodb-source-dns-seed-list"></a>

The **Use Srv** setting indicates whether you connect to a [DNS seed list](https://docs.mongodb.com/manual/reference/connection-string/#dns-seed-list-connection-format).

By default, the toggle is in the off position.

If you connect to a DNS seed list, then toggle the setting to the on position.

### Connection security settings <a href="#source-connection-security" id="source-connection-security"></a>

For the source connection, you can also:

* [Use SSL/TLS to encrypt authentication.](/app/workspace/workspace-configuration-settings/data-connection-settings/ensuring-encryption-of-database-authentication.md)
* [Trust the server certificate.](/app/workspace/workspace-configuration-settings/data-connection-settings/trusting-the-server-certificate.md)
* [Provide your own client and root certificate files.](/app/workspace/workspace-configuration-settings/data-connection-settings/providing-your-own-client-certificates.md)

## Connecting to the destination database <a href="#mongodb-data-connection-destination" id="mongodb-data-connection-destination"></a>

The **Destination Settings** section contains the connection information for the destination database.

### Copying the connection details from the source database <a href="#mongodb-data-connection-destination-copy-source" id="mongodb-data-connection-destination-copy-source"></a>

To copy the connection and authentication details from the source database:

1. Click **Copy Settings from Source**.
2. For **Password**, you can either specify the password manually or, if secrets managers are available, you can [select a secret name from a secrets manager](/app/workspace/workspace-configuration-settings/secrets-manager/selecting-a-secrets-manager-secret.md).
3. To test the connection to the destination database, click **Test Destination Connection**.

### Providing destination database connection details <a href="#mongodb-data-connection-destination-details" id="mongodb-data-connection-destination-details"></a>

If you don't copy the details from the source database, then you can either populate the connection fields or use a connection string.

#### Populating the connection fields <a href="#mongodb-data-connection-destination-details-fields" id="mongodb-data-connection-destination-details-fields"></a>

By default, **Use connection string** is off, and you provide the connection values in the individual fields:

1. In the **Server** field, provide the host name or IP address of the MongoDB instance.
2. In the **Database** field, provide the name of the MongoDB database.
3. In the **Port** field, provide the port number to connect to the server host.
4. In the **Username** field, provide the username of a MongoDB user in your authentication database.
5. For **Password**, you can either specify the password manually or, if secrets managers are available, you can [select a secret name from a secrets manager](/app/workspace/workspace-configuration-settings/secrets-manager/selecting-a-secrets-manager-secret.md).
6. In the **Authentication Database**, provide the database where the MongoDB user that you authenticate with is stored. The default is often the admin database.
7. To test the connection to the destination database, click **Test Destination Connection**.

#### Using a connection string <a href="#mongodb-data-connection-destination-details-connection-string" id="mongodb-data-connection-destination-details-connection-string"></a>

To use a connection string to connect to the destination database:

1. Toggle **Use Connection String** to the on position.
2. In the **Connection String** field, provide a [MongoDB connection string](https://docs.mongodb.com/manual/reference/connection-string/).\
   \
   For the password, use `<password>` as a placeholder value.
3. In the **Database** field, provide the name of the MongoDB database.
4. In the **Password** field, provide the password to use to replace `<password>`.
5. To provide the user password to replace  `<password>`, you can either specify the password manually, or you can [select a secret name from a secrets manager](/app/workspace/workspace-configuration-settings/secrets-manager/selecting-a-secrets-manager-secret.md). The selected secret must store a password.
6. To test the connection to the destination database, click **Test Destination Connection**.

### Using a DNS seed list <a href="#mongodb-destination-dns-seed-list" id="mongodb-destination-dns-seed-list"></a>

The **Use Srv** setting indicates whether you connect to a [DNS seed list](https://docs.mongodb.com/manual/reference/connection-string/#dns-seed-list-connection-format).

By default, the toggle is in the off position.

If you connect to a DNS seed list, then toggle the setting to the on position.

### Connection security settings <a href="#destination-connection-security" id="destination-connection-security"></a>

For the destination connection, you can also:

* [Use SSL/TLS to encrypt authentication.](/app/workspace/workspace-configuration-settings/data-connection-settings/ensuring-encryption-of-database-authentication.md)
* [Trust the server certificate.](/app/workspace/workspace-configuration-settings/data-connection-settings/trusting-the-server-certificate.md)
* [Provide your own client and root certificate files.](/app/workspace/workspace-configuration-settings/data-connection-settings/providing-your-own-client-certificates.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/setting-up-your-database/mongodb/mongodb-workspace-data-connections.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
