Docs Menu

Docs HomeView & Analyze DataMongoDB Compass

Import Saved Connections with the CLI

On this page

  • Prerequisite
  • Import Encrypted Saved Connections
  • Procedure
  • Example
  • Errors
  • Import Unencrypted Saved Connections
  • Procedure
  • Example

You can use the Compass CLI to import saved connections. This lets you use saved connections from other workspaces or connections used by other team members.

To import saved connections, you must first export the connections.

Use this procedure to import a list of saved connections that is encrypted with a passphrase.

To import unencrypted saved connections with the Compass CLI, specify:

  • The path to the MongoDB Compass executable. The name and filepath of the executable depend on your operating system.

  • The --import-connections option set to the destination of the file containing saved connections.

  • The --passphrase option set to the passphrase used to encrypt the exported file.

Your operation should resemble the following prototype:

<path-to-Compass-executable> \
--import-connections=<filename> \
--passphrase=<passphrase>

The following example imports saved Compass connections from a file with the path /tmp/compass-connections/favorites-encrypted.json that is encrypted with the passphrase abc123.

Run the following command in the folder containing your MongoDB Compass executable:

./MongoDB\ Compass \
--import-connections=/tmp/compass-connections/favorites-encrypted.json \
--passphrase=abc123

Note

The name and file path of the executable depend on your operating system. The preceding command is for macOS.

After you run the import command, you will see this output:

Importing connections from "/tmp/compass-connections/favorites-encrypted.json" (with passphrase)

MongoDB Compass starts and you will see the imported connections under Saved Connections on the Connect screen.

When you try to import encrypted saved connections, you may see these errors:

  • If do not specify a passphrase, you will see this error:

    Failed to perform operation Be [Error]: Input file contains encrypted
    secrets but no passphrase was provided
  • If you specify an incorrect passphrase, you will see this error:

    Failed to perform operation Be [Error]: Cannot decrypt due to corrupt
    data or wrong passphrase

Use this procedure to import a list of saved connections that is not encrypted with a passphrase.

To import unencrypted saved connections with the Compass CLI, specify:

  • The path to the MongoDB Compass executable. The name and file path of the executable depend on your operating system.

  • The --import-connections option set to the destination of the file containing saved connections.

Your operation should resemble the following prototype:

<path-to-Compass-executable> --import-connections=<filename>

The following example imports saved Compass connections from a file with the path /tmp/compass-connections/favorites.json.

Run the following command in the folder containing your MongoDB Compass executable:

./MongoDB\ Compass --import-connections=/tmp/compass-connections/favorites.json

Note

The name and file path of the executable depend on your operating system. The preceding command is for macOS.

After you run the import command, you will see this output:

Importing connections from "/tmp/compass-connections/favorites.json" (without passphrase)

MongoDB Compass starts and you will see the imported connections under Saved Connections on the Connect screen.

← Export Saved Connections with the CLI