Hide Credentials in Your Connection String
On this page
When you paste a connection string into the MongoDB Compass connection form,
Compass shows credentials in plaintext by default. To hide credentials in
the connection string, use the protectConnectionStrings
option.
About This Task
When protectConnectionStrings
is enabled, users cannot perform the following
actions:
Edit the connection string in the Compass connection form.
Copy the connection string in the Compass interface.
See the credentials when exporting a query.
Procedure
To hide your your connection string credentials, enable the
protectConnectionStrings
option.
You can set the protectConnectionStrings
option in either:
The Compass Settings panel
The command line
Compass Settings Panel
Command Line Example
The following command starts Compass from the command line and sets
the --protectConnectionStrings
option:
<path-to-Compass-executable> --protectConnectionStrings
Note
The name and filepath of the Compass executable depend on your operating system.
Configuration File Example
You can specify the Compass configuration file in either EJSON
or YAML format. The following configurations set the
protectConnectionStrings
option to true
:
EJSON
{ "protectConnectionStrings": true }
YAML
protectConnectionStrings: true
Learn More
To learn more about the MongoDB Compass configuration file, see Configuration File Settings.