postgresql - 在docker环境下为tcp md5配置Postgres

标签 postgresql jdbc docker tcp md5

我正在尝试配置 Postgres 以接收带有 md5 加密密码的连接。我阅读了大量手册并按照说明进行操作,但我还是失败了。

我们有几个 docker 容器,其中一个是我们使用 init_db.sh 脚本配置的 Postgres 9 容器。运行容器的最终配置是:

listen_addresses = '*'
local all all md5
host all all all md5

运行:lsof -i tcp:5432(我现在在我的 Mac 上运行),产生了这个:

COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 17454 sigals   36u  IPv4 0x13ec351b99f025cd      0t0  TCP *:postgresql (LISTEN)
com.docke 17454 sigals   37u  IPv6 0x13ec351b8ce8a025      0t0  TCP localhost:postgresql (LISTEN)

当我启动使用加密密码运行的容器时,我得到: 错误 org.apache.tomcat.jdbc.pool.ConnectionPool:182 - 无法创建池的初始连接。

2017-02-08T14:07:43.438478547Z org.postgresql.util.PSQLException: FATAL: password authentication failed for user "myuser"

当我将密码作为明文输入时,它会起作用。

当我将 IP 配置为仅本地主机时,加密和明文密码均有效。

我哪里配置错了?

最佳答案

According to docs:

md5 Require the client to supply a double-MD5-hashed password for authentication. See Section 20.3.2 for details.

password Require the client to supply an unencrypted password for authentication. Since the password is sent in clear text over the network, this should not be used on untrusted networks. See Section 20.3.2 for details.

jdbc 连接会散列您在连接字符串中提供的密码 - 您不必自己对其进行 md5。

另请看这里: https://stackoverflow.com/a/39038852/5315974

关于postgresql - 在docker环境下为tcp md5配置Postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42115387/

相关文章:

java - 如何从 hibernate auto ddl 中排除架构

java - 使用 jdbc 程序连接到 Open Office odb 文件

amazon-web-services - AWS Elastic Beanstalk、Dockerrun.aws.json 和 docker run 上的多个端口

mongodb - 如何在云运行上为 docker 容器关联持久卷

node.js - 如何在 Node.js 项目上的 Azure VM 中通过 IP 连接容器?

sql - 从加入的(1 到许多)postgresql 接收 1 行

sql - 函数返回单个列中的数据,而不是 3 个单独的列

python - 获取在 psycopg2 中插入的多行的 ID

java - JDBC连接远程oracle数据库在jdk 7和8中不起作用,但在jdk 6中可以工作?

Java MySQL 更新查询