docker 安装postgresql,开启远程访问
postgresql数据库开启远程访问
1.docker安装数据库
docker run --name postgresql14 -v /mysoft/postgresql/datadir:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -d -p 5432:5432 postgres:14.1
我这里将postgresql的数据目录映射到了本地/mysoft/postgresql/datadir目录
2.解决org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host
在使用navicat连接postgresql或者编写java代码时报错
org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host
编辑/mysoft/postgresql/datadir/pg_hba.conf文件
将host all all 0.0.0.0/0 md5
插入到# IPv4 local connections:
条目下面,表示允许所有的ip访问此数据库。
也可以允许指定的ip(如119.168.2.20)访问数据库host all all 119.168.2.20/32 md5
版权声明:本文为KaiKaiWaWa原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。