简体   繁体   English

将 postgres 从本地计算机连接到 docker 时,用户的密码身份验证失败

[英]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.

相关问题 连接到在 Docker 中运行的 postgres 时出错:pq:用户“postgres”的密码验证失败 - Getting an error while connecting to postgres running in Docker: pq: password authentication failed for user “postgres” 致命:连接到 postgres 时,用户“postgres”的密码身份验证失败 - FATAL: password authentication failed for user "postgres" While connecting to postgres postgres / docker:用户的密码身份验证失败 - postgres / docker: password authentication failed for user 用户“postgres”的 Docker 密码认证失败 - Docker password authentication failed for user “postgres” Docker postgres映像中的用户密码验证失败 - Password authentication failed for user in Docker postgres image org.postgresql.util.PSQLException:致命:从 Spring Boot 连接到 postgress 时,用户“postgres”的密码验证失败 - org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres" while connecting to postgress from Spring Boot 用户“postgres”的 Docker postgres 9.4 密码认证失败 - Docker postgres 9.4 password authentication failed for user “postgres” Docker Django Postgres 致命:用户“postgres”的密码验证失败 - Docker Django Postgres FATAL: password authentication failed for user "postgres docker-compose:致命:用户“postgres”的密码身份验证失败 - docker-compose: FATAL: password authentication failed for user "postgres" Postgres docker 错误:致命:用户密码验证失败 - Postgres docker error: FATAL: password authentication failed for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM