MongoDB connection

To access your data in MongoDB, create a connection asset for it.

MongoDB is a distributed database that stores data in JSON-like documents.

Supported editions and versions

MongoDB editions

MongoDB versions

  • MongoDB 3.6 and later, 4.x, 5.x, and 6.x
  • Microsoft Azure Cosmos DB for MongoDB 3.6 and later, 4.x

Create a connection to MongoDB

To create the connection asset, you need these connection details based on your deployment:

Common connectivity

  • Hostname or IP address: The hostname or IP address of the database.
  • Port number: The port of the database.
  • Authentication database: The name of the database in which the user was created.
  • Database: This is the name of the database. If you do not enter a database name, you must enter the catalog name, schema name, and the table name in the properties for SQL queries.
  • Column discovery sample size: The number of rows sampled per collection to determine table schemas. The default value is 1000.
  • Schema filter: A comma-separated list of database collection pairs for which the driver should fetch metadata.
  • Special character behaviour: Specifies what should be done to special characters in names that do not conform to SQL identifier syntax. The options you can choose from are:
    • Include: Leave the special characters and keep them in the name.
    • Replace: Replace the special characters with underscores.
    • Strip: Remove the special characters. This is the default action.

Credentials

You have specific authentication methods based on your deployment:

Common connectivity

  • Username and password

Certificates

You can enable SSL for each deployment:

Common connectivity

  • Port is SSL-enabled: Enable this option if the port you have chosen is configured to accept SSL connections.

If the Port is SSL-enabled option is enabled, fill in the following fields:

  • SSL certificate: Enter the SSL certificate of the host to be trusted
  • Hostname in SSL certificate: The hostname in SubjectAlternativeName or Common Name (CN) part of the SSL certificate
  • Validate the SSL certificate: Enable this option to validate that the SSL certificate returned by the host is trusted.

For Credentials and Certificates, you can use secrets if a vault is configured for the platform and the service supports vaults. For information, see Using secrets from vaults in connections.

Federal Information Processing Standards (FIPS) compliance

The MongoDB connection cannot be created in a FIPS environment.

MongoDB setup

MongoDB installation

Restrictions

  • You can only use this connection for source data. You cannot write to data or export data with this connection.
  • MongoDB Query Language (MQL) is not supported.

Learn more

Related connection: IBM Cloud Databases for MongoDB connection