Command Line Options - Compass - MongoDB Docs
Docs Home / Compass / Customize

Command Line Options命令行选项

You can customize MongoDB Compass using command line options.您可以使用命令行选项自定义MongoDB Compass。

Definition定义

You can start MongoDB Compass and set configuration options from the command line. When you use the command line to set configuration options, the options are set at startup. Settings configured using command line options cannot be modified on the Compass interface.您可以启动MongoDB Compass并从命令行设置配置选项。当您使用命令行设置配置选项时,这些选项将在启动时设置。无法在Compass界面上修改使用命令行选项配置的设置。

Compass Executable LocationCompass可执行位置

The name and location of the Compass executable varies by operating system.Compass可执行文件的名称和位置因操作系统而异。

Operating System操作系统Executable Name可执行文件名Location位置
Linuxmongodb-compassThe installer installs it in the /usr/bin directory.安装程序将其安装在/usr/bin目录中。
WindowsMongoDBCompass.exeThe installer installs it in a folder you pick during the installation process.安装程序会将其安装在您在安装过程中选择的文件夹中。
MacOSMongoDB Compass

The installer installs it under the Applications folder:安装程序将其安装在Applications文件夹下:

/Applications/MongoDB\ Compass.app/Contents/MacOS/MongoDB\ Compass

Syntax语法

Use the following syntax to start MongoDB Compass and set a configuration option:使用以下语法启动MongoDB Compass并设置配置选项:

<path-to-Compass-executable> --<option>

Options选项

Command Line Only仅限命令行

These options can only be set on the command line. These options cannot be set in the Settings panel or the Compass configuration file.这些选项只能在命令行上设置。这些选项无法在“设置”面板或Compass配置文件中设置。

Setting设置Definition定义
--exportConnectionsExport favorite connections.导出收藏的连接。
--helpShow MongoDB Compass options.显示MongoDBCompass选项。
--importConnectionsImport favorite connections.导入收藏的连接。
--passphrase

Specify a passphrase to encrypt the exported favorite connections output file.指定一个密码来加密导出的收藏夹连接输出文件。

Specify a passphrase to decrypt the imported favorite connections file.指定一个密码来解密导入的收藏夹连接文件。

--showExampleConfigProvides an example Compass configuration file.提供Compass配置文件示例。
--trustedConnectionString

Suppresses warnings about disallowed connection string properties and allows automatic connection. Compass inspects the connection string passed in the command line, and verifies whether the connection string contains parameters that can result in a security risk.抑制有关不允许的连接字符串属性的警告,并允许自动连接。Compass检查命令行中传递的连接字符串,并验证连接字符串是否包含可能导致安全风险的参数。

Only set this option if you pass a known trusted connection string to Compass.仅当您将已知的受信任连接字符串传递给Compass时,才设置此选项。

--versionShow MongoDB Compass version.显示MongoDB Compass版本。

General Settings常规设置

These options can be set on the command line, in a configuration file, or in the Settings panel. Setting an option on the command line overrides the value in the Settings panel.这些选项可以在命令行、配置文件或“设置”面板中设置。在命令行上设置选项会覆盖“设置”面板中的值。

Setting设置Definition定义
--autoUpdatesEnable automatic updates. Use --no-autoUpdates to disable automatic updates.启用自动更新。使用--no-autoUpdates禁用自动更新。
--browserCommandForOIDCAuthSpecifies a shell command to start the browser for OIDC authentication when you connect to the server or log into your Atlas Cloud account.指定一个shell命令,以便在连接到服务器或登录Atlas Cloud帐户时启动浏览器进行OIDC身份验证。
--enableFeedbackPanelEnable the feedback panel. Use --no-enableFeedbackPanel to disable automatic updates.启用反馈面板。使用--no-enableFeedbackPanel禁用自动更新。
--enableDevTools

Enable Chrome DevTools in Compass.在Compass中启用Chrome DevTools。

To learn more, see Toggle Chrome DevTools.要了解更多信息,请参阅切换Chrome DevTools

--enableGenAIFeaturesAllow Compass to use generative AI for natural language querying.允许Compass使用生成式人工智能进行自然语言查询。
--enableGenAISampleDocumentPassing

Allow MongoDB Compass to send sample field values with query and aggregation generation requests. These values can improve the results from the AI.允许MongoDB Compass通过查询和聚合生成请求发送示例字段值。这些值可以改善AI的结果。

If true, this option implicitly sets the --enableGenAIFeatures option to true.如果为true,则此选项隐式地将--enableGenAIFeatures选项设置为true

--enableMapsAllow MongoDB Compass to make requests to a 3rd party mapping service. Use --no-enableMaps to disable mapping requests.允许MongoDB Compass向第三方映射服务发出请求。使用--no-enableMaps禁用映射请求。
--enableShell

Enable or disable the embedded MongoDB Shell on Compass.启用或禁用Compass上的嵌入式MongoDB Shell。

To learn more, see Disable the Embedded MongoDB Shell.要了解更多信息,请参阅禁用嵌入式MongoDB Shell

--file <file>Specifies a file containing a list of connections that are automatically available once MongoDB Compass starts.指定一个文件,其中包含MongoDB Compass启动后自动可用的连接列表
--forceConnectionOptions

Assign connection option values for when you connect to your MongoDB deployment through Compass. These connection options cannot be overridden by connections from the Compass interface or a command line connection string.为通过Compass连接到MongoDB部署时分配连接选项值。这些连接选项不能被Compass界面的连接或命令行连接字符串覆盖。

To learn more, see Specify Read Preference and Tags.要了解更多信息,请参阅指定读取首选项和标记

--ignoreAdditionalCommandLineFlagsAllows additional command line flags.允许使用其他命令行标志。
--installURLHandlers

Register Compass as a handler for mongodb:// and mongodb+srv:// URLs.将Compass注册为mongodb://mongodb+srv://URL的处理程序。

If Install Compass as URL Protocol Handler is enabled, you can open Compass by navigating to a mongodb:// or mongodb+srv:// URL in your internet browser.如果启用了“将Compass安装为URL协议处理程序”,则可以通过在internet浏览器中导航到mongodb://mongodb+srv://URL来打开Compass。

Available on macOS and Windows.可在macOS和Windows上使用。

--maxTimeMSSpecify an upper time limit for all Compass database operations.为所有Compass数据库操作指定上限时间。
--networkTraffic

Configure MongoDB Compass to only allow outgoing network operations to connect to the database.将MongoDB Compass配置为只允许传出网络操作连接到数据库。

To learn more, see Block Outgoing Network Connections.要了解更多信息,请参阅阻止传出网络连接

--password

Specifies a password for authentication to Compass and the MongoDB deployment provided in the connection string.指定连接字符串中提供的Compass和MongoDB部署的身份验证密码。

Use in conjunction with --username.

--persistOIDCTokensAllows you to remain logged in when using the MongoDB OIDC authentication mechanism for MongoDB server connections. Session tokens are encrypted and stored using the system keychain.允许您在使用MongoDB OIDC身份验证机制进行MongoDB服务器连接时保持登录状态。会话令牌使用系统键链进行加密和存储。
--protectConnectionStrings

Sets all connection strings as read-only. Passwords in connection strings display as *****.将所有连接字符串设置为只读。连接字符串中的密码显示为*****

If protectConnectionStrings is enabled, Compass disables the Edit connection string option and hides the Edit connection string toggle.如果启用了protectConnectionStrings,Compass将禁用“编辑连接字符串”选项并隐藏编辑连接字符串切换。

To learn more, see Secure Your Connection String.要了解更多信息,请参阅保护连接字符串

--protectConnectionStringsForNewConnections

Sets connection strings for new connections as read-only by default. Passwords in new connection strings display as *****.默认情况下,将新连接的连接字符串设置为只读。新连接字符串中的密码显示为*****

If protectConnectionStringsForNewConnections is enabled, Compass disables the Edit connection string option but doesn't prevent users from manually enabling the option with the Edit connection string toggle.如果启用了protectConnectionStringsForNewConnections,Compass将禁用“编辑连接字符串”选项,但不会阻止用户使用编辑连接字符串切换手动启用该选项。

--readOnly

Prevent users from performing write operations to your MongoDB deployment through Compass.防止用户通过Compass对MongoDB部署执行写入操作。

To learn more, see Restrict Write Operations to MongoDB.要了解更多信息,请参阅将写入操作限制为MongoDB

--showInsights

Enables performance insights for your schemas and queries.为您的模式和查询提供性能洞察。

To learn more, see Performance Insights.要了解更多信息,请参阅性能洞察

--showKerberosPasswordField

Show or hide the Kerberos password field on the Compass connection form.显示或隐藏Compass连接窗体上的Kerberos密码字段。

To learn more, see Display the Kerberos Password Field.要了解更多信息,请参阅显示Kerberos密码字段

--showOIDCDeviceAuthFlowEnables device authorization flow for OIDC authentication on MongoDB server. This enables a less secure authentication flow that can be used as a fallback when browser-based authentication is unavailable.在MongoDB服务器上启用OIDC身份验证的设备授权流。这使得在基于浏览器的身份验证不可用时,可以使用不太安全的身份验证流作为回退。
--themeSpecify the MongoDB Compass UI theme. The supported themes are DARK, LIGHT, and OS_THEME.指定MongoDB Compass UI主题。支持的主题是DARK(深色)、LIGHT(浅色)和OS_THEME(系统主题)。
--trackUsageStatistics

Enable sending usage statistics. Use --no-trackUsageStatistics to disable sending usage statistics.启用发送使用统计信息。使用--no-trackUsageStatistics禁用发送使用情况统计信息。

To learn more, see Configure Telemetry Options.要了解更多信息,请参阅配置遥测选项

--username

Specifies a username for authentication to Compass and the MongoDB deployment provided in the connection string指定用于对Compass和连接字符串中提供的MongoDB部署进行身份验证的用户名

Optionally, use in conjuction with --password.可选地,与--password结合使用。

Note

To view all available Compass configuration options, run the following command in the folder containing your MongoDB Compass executable:要查看所有可用的Compass配置选项,请在包含MongoDB Compass可执行文件的文件夹中运行以下命令:

<path-to-Compass-executable> --help

Learn More了解更多