Skip to main content

MongoDB 高级连接字符串

对于 控制器 Server UI 持久层,您可以使用高级连接字符串连接到 MongoDB。如果需要支持以下功能,请使用高级连接字符串:

  • TLS/SSL

  • Replica Sets(副本集)

  • Sharding(分片)

  • MongoDB Atlas

重要

如果您在连接字符串选项推出之前(2020.1 版)使用了副本集,则必须更改为连接字符串。

连接字符串提示和示例

  • 支持的连接字符串参数取决于驱动程序。参数必须被以下列出的支持的驱动程序所支持,才能在连接字符串中使用。支持的驱动程序版本包括...

    • c 1.17 (mongoc)

    • c++ 3.6 (mongocxx)

    • c# 2.12 (mongoc#)

  • 用户名、密码或参数值中的特殊字符必须进行 URL 编码。

如需有关格式化连接字符串的帮助,请参阅 MongoDB 连接字符串文档

使用 SSL/TLS 的本地单节点示例:

mongodb://username:P%40ssw0rd@hostname.domain.tld:27017/AlteryxService?authSource=databasename&ssl=true

使用 SSL/TLS 的本地副本集示例:

mongodb://username:P%40ssw0rd@host01.domain.tld:27017,host02.domain.tld:27017,host03.domain.tld:27017/AlteryxService?authSource=databasename&replicaSet=rs0&ssl=true

Atlas 示例:

mongodb+srv://username:P%40ssw0rd@host-0-1mngx.mongodb.net/AlteryxService?retryWrites=true&w=majority

使用 SSL/TLS 的本地单节点示例:

mongodb://username:P%40ssw0rd@hostname.domain.tld:27017/AlteryxGallery?authSource=databasename&ssl=true

使用 SSL/TLS 的本地副本集示例:

mongodb://username:P%40ssw0rd@host01.domain.tld:27017,host02.domain.tld:27017,host03.domain.tld:27017/AlteryxGallery?authSource=databasename&replicaSet=rs0&ssl=true

Atlas 示例:

mongodb+srv://username:P%40ssw0rd@host-0-1mngx.mongodb.net/AlteryxGallery?retryWrites=true&w=majority

使用 SSL/TLS 的本地单节点示例:

mongodb://username:P%40ssw0rd@hostname.domain.tld:27017/AlteryxGallery_Lucene?authSource=databasename&ssl=true

使用 SSL/TLS 的本地副本集示例:

mongodb://username:P%40ssw0rd@host01.domain.tld:27017,host02.domain.tld:27017,host03.domain.tld:27017/AlteryxGallery_Lucene?authSource=databasename&replicaSet=rs0&ssl=true

Atlas 示例:

mongodb+srv://username:P%40ssw0rd@host-0-1mngx.mongodb.net/AlteryxGallery_Lucene?retryWrites=true&w=majority