Docs HomeMongoDB Compass

General Connection Tab“常规连接”选项卡

On this page本页内容

The General connection tab allows you to select a Connection String Scheme and configure the hostname or hosts used to connect to your MongoDB deployment.“常规”连接选项卡允许您选择“连接字符串方案”,并配置用于连接到MongoDB部署的主机名。

Procedure过程

1

Click Advanced Connection Options.单击“高级连接选项”。

New Advanced Connection Options
2

Click the General tab.单击“常规”选项卡。

1

Select a connection string scheme.选择一个连接字符串方案。

You can select one of the following options:您可以选择以下选项之一:

Connection String Scheme连接字符串方案Definition释义
mongodbStandard Connection String Format. 标准连接字符串格式The standard format of the MongoDB connection URI is used to connect to a MongoDB deployment by specifying its hosts directly.MongoDB连接URI的标准格式用于通过直接指定其主机来连接到MongoDB部署。
mongodb+srvDNS Seed List Connection FormatDNS种子列表连接格式. The +srv indicates to MongoDB Compass that the hostname that follows corresponds to a DNS SRV record.+srv向MongoDB Compass指示后面的主机名对应于DNS +srv记录。
2

Enter a Hostname.输入主机名。

In the Host field, enter the hosts or hostname of the server where the deployment is running.在“主机”字段中,输入正在运行部署的服务器的主机或主机名。

If you are running your deployment locally, this value is localhost. 如果您在本地运行部署,则此值为localhostIf you are connecting to an Atlas cluster, see Connect to Database Deployment for Atlas-specific guidance on how to connect with Compass.如果您正在连接到Atlas集群,请参阅连接到数据库部署以了解有关如何连接Compass的Atlas特定指南。

If you are not sure of your hostname, contact your Database Administrator for information.如果您不确定自己的主机名,请与数据库管理员联系以获取信息。

3

(Optional) Enable Direct Connection.(可选)启用直接连接。

When you use the mongodb Connection String Scheme, you have the option to enable a Direct Connection. When you enable this setting, Compass runs all operations on the specified host.当您使用mongodb连接字符串方案时,您可以选择启用直接连接。如果启用此设置,Compass将在指定主机上运行所有操作。

Important

When you specify directConnection and connect to a secondary member of a replica set, your write operations fail because it is not the primary member.指定directConnection并连接到副本集的辅助成员时,写入操作会失败,因为它不是主要成员。

3

(Optional) For advanced connection configuration options, click the Advanced tab.(可选)有关高级连接配置选项,请单击“高级”选项卡。

4

Click Connect.单击“连接”。

Tip

See also:

To disconnect from your deployment, see Disconnect from MongoDB.要断开与部署的连接,请参阅断开与MongoDB的连接