Skip to main content
To add a MongoDB database, go to Instances, click Connect instance, and choose MongoDB. Bytebase lists every database on the server except admin, config, and local as a Bytebase database. See Database.

Supported versions

Bytebase supports MongoDB 4.2 and later. It connects through a built-in driver, so there is nothing to install.

Create a user for Bytebase

On a self-managed deployment, connect with mongosh as a user administrator and create a dedicated user. The examples name it bytebase.
The user is defined in admin, so leave Authentication Database empty. For a read-only connection, create a user with only readAnyDatabase:
On MongoDB Atlas, create the user in the Atlas UI instead, because Atlas rolls back users created with db.createUser. Under Security, click Database & Network Access, open the Database Users tab, and click Add New Database User. Choose Password, then pick Atlas admin under Built-in Role, or Only read any database for the read-only user.

Connection details

Hostname

The host name or IP address of a MongoDB server, such as db.example.com. With mongodb+srv://, enter the deployment’s DNS name instead, such as cluster0.example.com. With Verify server certificate on, the host name must be one of the names in the server’s certificate.

Port

The server port. MongoDB’s default is 27017. With mongodb+srv://, the ports come from DNS, so the field isn’t available.

Connection String Schema

  • mongodb://: Bytebase connects to the hosts you enter.
  • mongodb+srv://: Bytebase looks up the hosts in the DNS SRV record for Hostname, as MongoDB Atlas connection strings do. Choosing it clears Port, Additional Node Addresses, Replica Set, and Direct Connection.

Additional Node Addresses

Other hosts of the same deployment. Bytebase tries them all, so it can connect while the first host is down.

Replica Set

The name of the replica set, such as rs0. Bytebase finds the members and works with the primary.

Direct Connection

Connects only to the host you entered, without finding the other members of the replica set. Use it to reach one member on its own.

Username

The MongoDB user Bytebase connects as.

Password

The user’s password. You can also read it from a secret manager.

Authentication Database

The database where the user is defined. If you leave it empty, Bytebase uses admin. Set it for a user created in another database.

TLS

TLS mode decides whether Bytebase encrypts the connection:
  • Disabled: the connection is unencrypted.
  • TLS: Bytebase encrypts the connection.
  • Mutual TLS: the same as TLS, and Bytebase also presents a client certificate, for servers that require one.
Under Server identity, turn on Verify server certificate so that Bytebase checks the server’s certificate and confirms that Hostname is one of the names in it. CA certificate source sets which certificate authority (CA) the check trusts:
  • System trust: the CAs that the machine running Bytebase already trusts.
  • Paste PEM: a CA certificate you paste in PEM format, for a private CA or a self-signed certificate.
  • File path: a CA certificate file on the Bytebase server. Not available in Bytebase Cloud.
With verification off, the connection is encrypted, but Bytebase doesn’t check which server it reached. Use that only for testing. For Mutual TLS, set Client identity source to Paste PEM or File path, and provide the client certificate and its private key.

Extra Parameters

Connection string options that Bytebase adds to the URI, such as readPreference. Set TLS in the TLS section instead: tls with the value true here checks the server only against the CAs that the machine running Bytebase trusts.

Troubleshooting

Test Connection shows the error from the server or the driver:

Read-only connection

A read-only connection has its own TLS settings and Extra Parameters. Set them the same way as for the admin connection.