根据文档https://www.mongodb.com/docs/v4.4/reference/connection-string/#std-label-connections-dns-seedlist mongodb+srv://server.example.com/
相当于_mongodb._tcp.server.example.com
的记录。
但是,我有多个Mongo服务,我想连接到_mymongodb._tcp.server.example.com
。我如何指定使用mymongodb
服务名称而不是mongodb
?我已经盯着文档看了几个小时,似乎找不到答案。
1条答案
按热度按时间sz81bmfz1#
It's not possible, the string
_mongodb._tcp
is prefixed with the host name, and it is hardcoded in the source code. https://github.com/mongodb/mongo/blob/3e63636e66ced4aed6d1aaaafcdca7ae19cf96f2/src/mongo/client/mongo_uri.cpp#L408The only possible way is to handle that manually, for example in Linux shell with: