文档首页> 文档数据库服务 DDS> 故障排除> 连接失败,提示:exception: login failed 以及 U_STRINGPREP_PROHIBITED_ERROR
更新时间:2021-11-23 GMT+08:00
分享

连接失败,提示:exception: login failed 以及 U_STRINGPREP_PROHIBITED_ERROR

问题描述

使用如下命令连接DDS实例时报错。

./mongo "mongodb://rwuser:xxxxxx@192.168.0.45:8635,192.168.0.96:8635/test?authSource=admin&replicaSet=replica"

报错信息如下:

MongoDB shell version v4.0.3
connecting to: mongodb://192.168.0.45:8635,192.168.0.96:8635/test?authSource=admin&replicaSet=replica
2021-11-05T05:52:53.717+0000 I NETWORK  [js] Starting new replica set monitor for replica/192.168.0.45:8635,192.168.0.96:8635
2021-11-05T05:52:53.718+0000 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to 192.168.0.45:8635 (1 connections now open to 192.168.0.45:8635 with a 5 second timeout)
2021-11-05T05:52:53.718+0000 I NETWORK  [js] Successfully connected to 192.168.0.96:8635 (1 connections now open to 192.168.0.96:8635 with a 5 second timeout)
Implicit session: session { "id" : UUID("5945d2a5-8275-4e3c-b06f-632f062a2ead") }
MongoDB server version: 4.0.3
2021-11-05T05:52:53.722+0000 I NETWORK  [js] Marking host 192.168.0.96:8635 as failed :: caused by :: Location50692: can't authenticate against replica set node 192.168.0.96:8635 :: caused by :: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR
2021-11-05T05:52:53.722+0000 I NETWORK  [js] Successfully connected to 192.168.0.45:8635 (1 connections now open to 192.168.0.45:8635 with a 0 second timeout)
2021-11-05T05:52:53.723+0000 I NETWORK  [js] Marking host 192.168.0.45:8635 as failed :: caused by :: Location50692: can't authenticate against replica set node 192.168.0.45:8635 :: caused by :: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR
2021-11-05T05:52:53.724+0000 I NETWORK  [js] Marking host 192.168.0.96:8635 as failed :: caused by :: Location50692: can't authenticate against replica set node 192.168.0.96:8635 :: caused by :: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR
2021-11-05T05:52:53.725+0000 I NETWORK  [js] Marking host 192.168.0.45:8635 as failed :: caused by :: Location50692: can't authenticate against replica set node 192.168.0.45:8635 :: caused by :: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR
2021-11-05T05:52:53.725+0000 E QUERY    [js] Error: can't authenticate against replica set node 192.168.0.45:8635 :: caused by :: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1685:20
@(auth):6:1
@(auth):1:2
exception: login failed

可能原因

输入的实例密码异常。

排查思路

  • 检查设置的DDS实例密码中是否有‘@’、‘%’和‘!’字符,如果有,需要转义。
  • DDS实例当前支持的特殊字符,有(~ !@ # % ^ * - _ = + ?,其中使用%@需要转义)。

处理方法

方法一:修改DDS实例的密码,新密码中不能包含‘@’、‘%’和‘!’字符。

方法二:连接DDS实例时,需要分别将‘@’、‘%’和‘!’字符进行转义,替换为对应的十六进制的URL编码(ASSCII码)“%40”、“%25”和“%21”。

例如:密码为****@%***!,对应的URL编码为****%40%25***%21。

背景知识

‘@’、‘%’和‘!’字符在DDS实例连接时会作为特殊的字符进行处理,如果设置的DDS实例中使用了上述字符,在使用高可用连接地址连接DDS实例时,需要对其进行转义处理,否则不能得到预期的解析。

分享:

    相关文档

    相关产品

close