[英]password authentication failed for user while connecting postgres from local machine to docker
I'm using docker container to connect postgres connection from my local machine to docker to import open street map data.我正在使用 docker 容器将 postgres 连接从我的本地机器连接到 docker 以导入开放的街道地图数据。 But I'm getting authentication failed for user.
但是我的用户身份验证失败。
docker run --name "postgis" -p 5432:5432 -d -t kartoza/postgis:11.5-2.8
my pg_hba.conf file is我的 pg_hba.conf 文件是
# TYPE DATABASE USER ADDRESS METHOD # IPv4 local connections: host all all 172.17.0.1/16 md5 host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. host replication all 127.0.0.1/32 md5 host replication all 172.17.0.1/16 md5 host replication all ::1/128 md5
I have changed md5 to trust
also but still I'm facing below issue.我也将
md5 to trust
更改md5 to trust
但我仍然面临以下问题。
2020-10-14 04:56:53.055 UTC [166] postgres@gis FATAL: password authentication failed for user "postgres" 2020-10-14 04:56:53.055 UTC [166] postgres@gis DETAIL: User "postgres" has no password assigned. Connection matched pg_hba.conf line 100: "host all all 172.0.0.0/8 md5"
and my postgres version is 11.9 and client is 11.8 and IP is "IPv4Address": "172.17.0.2/16"
我的postgres 版本是 11.9,客户端是 11.8 ,IP 是
"IPv4Address": "172.17.0.2/16"
How can I resolve Please suggest me我该如何解决 请建议我
Initially I used localhost:5432,127.0.0.1:5432 and 172.17.0.1:5432
in db connection string that causes this issue.最初我在导致此问题的数据库连接字符串中使用了
localhost:5432,127.0.0.1:5432 and 172.17.0.1:5432
。
After using below host address in connection string my issue resolved在连接字符串中使用以下主机地址后,我的问题解决了
host.docker.internal:5432
postgres://db_user:db_password@host.docker.internal:5432/db
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.