【问题标题】:Failed Connect CockroachDB using password include "#"使用密码连接 CockroachDB 失败包括“#”
【发布时间】:2020-12-22 07:13:25
【问题描述】:

所以我尝试使用连接字符串连接 cockroach db,我有密码包含 # 但无法连接

这里蟑螂文档:https://www.cockroachlabs.com/docs/stable/connection-parameters.html

当我使用下面的命令并手动输入密码时,它正在工作

cockroach sql --url "postgres://taperaxxx@10.xxx.xx.xx:26257/sitaxxx?sslmode=verify-full&sslrootcert=E:/ca.crt"

但是当在连接字符串中包含密码时连接失败

cockroach sql --url "postgres://taperaxxx:#samplepassword#@10.xxx.xx.xx:26257/sitarxxx?sslmode=verify-full&sslrootcert=E:/ca.crt"

执行带有密码的命令时出现这里错误

错误:无法加载证书。 检查您的证书设置,设置 --certs-dir,或对不安全的集群使用 --insecure。 CA 证书问题:未找到运行“sql”失败

注意:我尝试连接另一个蟑螂数据库,在连接字符串中包含密码(不带#)并成功。

如果此错误或我错过了文档,请告诉我。

谢谢

【问题讨论】:

    标签: cockroachdb


    【解决方案1】:

    # 是 URL 中的特殊字符,必须进行编码。

    使用percent encoding %23 发送实际的#

    你的命令行现在变成:

    cockroach sql --url "postgres://taperaxxx:%23samplepassword%23@10.xxx.xx.xx:26257/sitarxxx?sslmode=verify-full&sslrootcert=E:/ca.crt"
    

    【讨论】:

      猜你喜欢
      • 2022-08-05
      • 1970-01-01
      • 2017-07-09
      • 2017-12-29
      • 2011-09-30
      • 1970-01-01
      • 2022-07-18
      • 2020-07-10
      • 2011-11-04
      相关资源
      最近更新 更多