解决 Odyssey 报错 SCRAM-SHA-256 client authentication failed 密码协议不匹配修复
排查 客户端使用 SCRAM 认证连接 Odyssey 报 scram-sha-256 authentication failed 或 Unsupported authentication type,分析 密码认证模式转换与用户映射。
问题现象
PostgreSQL 14 开启 SCRAM-SHA-256 后,客户端通过 Odyssey 代理时认证失败:
fatal: password authentication failed for user 'webapp'
Odyssey log: [auth] authentication failure: unsupported or mismatch scram auth mechanism
触发根因
- Odyssey 在早前版本中对客户端原生的 SCRAM-SHA-256 透传需要显式配置支持;
- Odyssey 内部配置的认证类型(
authentication)声明为了md5或clear_text,与客户端发出的 SCRAM 挑战报文产生冲突。
解决步骤
在 Odyssey 中正确声明 scram-sha-256 密码鉴权
在 odyssey.conf 数据库或用户规则块中明确指定:
database default {
user "webapp" {
authentication "scram-sha-256"
password "SCRAM-SHA-256$4096:5a...==:1b...=="
pool "transaction"
}
}
或者让 Odyssey 作为透明透传代理
在用户配置中配置透传至后端数据库验证:
user "webapp" {
authentication "none"
storage_password "my_actual_password"
pool "transaction"
}
验证确认
重载 Odyssey 进程:
客户端顺利通过 SCRAM 握手完成安全认证与查询执行。


