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过程
Click the General tab.单击“常规”选项卡。
Select a connection string scheme.选择一个连接字符串方案。
You can select one of the following options:您可以选择以下选项之一:
mongodb | |
mongodb+srv | +srv indicates to MongoDB Compass that the hostname that follows corresponds to a DNS SRV record.+srv 记录。 |
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
. localhost
。If 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.如果您不确定自己的主机名,请与数据库管理员联系以获取信息。
(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将在指定主机上运行所有操作。
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
并连接到副本集的辅助成员时,写入操作会失败,因为它不是主要成员。
See also:
To disconnect from your deployment, see Disconnect from MongoDB.要断开与部署的连接,请参阅断开与MongoDB的连接。