docker-compose部署postgresql
- docker-compose.yml
version: '3.1'
services:
postgresdb:
image: postgres
container_name: postgres
restart: on-failure:500
environment:
POSTGRES_USER: xxx
POSTGRES_PASSWORD: xxxx
volumes:
- ./data:/var/lib/postgresql/data
- ./conf:/usr/share/postgresql
ports:
- 5432:5432
networks:
default:
external:
name: you-docker-compose-network
- navicat连接postgres时显示authentication method 10 not supported
解决办法:
编辑/var/lib/pgsql/14/data/pg_hba.conf
第一步,将原来的这些注释掉
# TYPE DATABASE USER ADDRESS METHOD
# "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
#host all all 0.0.0.0/0 password
第二步,新增加这些内容
# "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
host all all 0.0.0.0/0 password
然后使用用户名密码尝试登录吧