使用包含“#”的密码连接 CockroachDB 失败

Failed Connect CockroachDB using password include "#"

所以我尝试使用连接字符串连接 cockroach 数据库,我有密码 include # 但连接失败

这里是蟑螂文档: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"

执行包含密码的命令时出现错误

ERROR: cannot load certificates. Check your certificate settings, set --certs-dir, or use --insecure for insecure clusters. problem with CA certificate: not found Failed running "sql"

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

如果这个错误或我遗漏了文档,请告诉我。

谢谢

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

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

您的命令行现在变为:

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