一佳一

记录像1+1一样简洁的代码

导航

docker安装postgresql

Posted on 2022-07-02 10:31  一佳一  阅读(178)  评论(0编辑  收藏  举报

1.拉取镜像

 docker pull postgres

2.运行 挂在到data 没有目录的记得先创建

docker run --name postgres \
    --restart=always \
    -e POSTGRES_PASSWORD=123456 \
    -p 5432:5432 \
    -v /data/postgresql:/var/lib/postgresql/data \
    -d postgres

3.修改远程端口配置文件

3.1 修改 postgres/data/postgresql.conf 去掉端口注释

 

 

 3.2 修改 pg_hba.conf 注释原来的

添加自己的IP  我的是192.168.0.168

# "local" is for Unix domain socket connections only
local   all             all                           trust
# IPv4 local connections:
host    all             all             192.168.0.168/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

4.用navicat 连接测试