admin管理员组文章数量:1396746
I have a docker container running a postgresql database. When i access the container (docker exec -it my-docker
) and then try to connect to my database(psql -U myuser
) and type my password the connection works.
But then wwhen i try the command psql -h localhost -p 5432 -U myuser
and type my same password i get an error.
Does anyone know what can be the problem here?
Needed Information
OS : Windows 10 Pro
Tools: Docker Desktop
Error: psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "myuser"
docker-compose.yml:
services:
postgres:
image: postgres:15
container_name: mycontainer
restart: always
environment:
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypass
POSTGRES_DB: mydb
ports:
- "5432:5432"
networks:
- mynetwork
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
networks:
mynetwork:
driver: bridge`
pg_hba.conf:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all all scram-sha-256
postgresql.conf:
# PostgreSQL configuration file
# -----------------------------
#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*'
#port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
shared_buffers = 128MB # min 128kB
dynamic_shared_memory_type = posix # the default is usually the first option
#------------------------------------------------------------------------------
# WRITE-AHEAD LOG
#------------------------------------------------------------------------------
max_wal_size = 1GB
min_wal_size = 80MB
#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# QUERY TUNING
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# REPORTING AND LOGGING
#------------------------------------------------------------------------------
log_timezone = 'Etc/UTC'
#------------------------------------------------------------------------------
# PROCESS TITLE
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# STATISTICS
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#------------------------------------------------------------------------------
# - Locale and Formatting -
datestyle = 'iso, mdy'
timezone = 'Etc/UTC'
lc_messages = 'en_US.utf8' # locale for system error message
lc_monetary = 'en_US.utf8' # locale for monetary formatting
lc_numeric = 'en_US.utf8' # locale for number formatting
lc_time = 'en_US.utf8' # locale for time formatting
default_text_search_config = 'pg_catalog.english'
本文标签: Cannot connect to my PostgreSQL Docker Database from my Windows EnvironmentStack Overflow
版权声明:本文标题:Cannot connect to my PostgreSQL Docker Database from my Windows Environment - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744128714a2592074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论