PostgreSQL10允许远程访问配置

  • A+
所属分类:ODOO项目

安装PostgreSQL10数据库之后,默认只能本地访问连接。如果想在其他主机上访问PostgreSQL10数据库服务器,就需要对pg_hba.conf和postgresql.conf这两个文件进行配置。
所在目录如下:

  1. /var/lib/pgsql/10/data/  

1.修改pg_hba.conf文件

在data/pg_hba.conf中

  1. 在data/pg_hba.conf中  
  2.   
  3. # TYPE  DATABASE        USER            ADDRESS                 METHOD   
  4.   
  5. # IPv4 local connections:  
  6. host    all             all             127.0.0.1/32            md5  
  7. host    all             all             0.0.0.0/0                  md5          

2.修改postgresql.conf文件

在安装目录下data/postgresql.confi文件中将

  1. #listen_addresses='localhost’  

修改为

  1. listen_addresses = '*'   

修改完成后重启数据库

  1. root@localhost data]# systemctl restart postgresql-10  

附:查看监听的端口

  1. [root@localhost data]# netstat -antpl  
  2. Active Internet connections (servers and established)  
  3. Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name      
  4. tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1286/cupsd            
  5. tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      3985/postmaster       
  6. tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1495/master           
  7. tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      3079/sshd: root@pts   
  8. tcp        0      0 0.0.0.0:8069            0.0.0.0:*               LISTEN      4031/python3          
  9. tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd             
  10. tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1775/dnsmasq          
  11. tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1290/sshd             
  12. tcp        0      0 10.128.25.135:5432      10.128.30.218:61157     ESTABLISHED 4041/postgres: post   
  13. tcp        0      0 10.128.25.135:5432      10.128.30.218:61160     ESTABLISHED 4042/postgres: post   
  14. tcp        0      0 10.128.25.135:5432      10.128.30.218:61161     ESTABLISHED 4043/postgres: post   
  15. tcp        0     52 10.128.25.135:22        10.128.30.218:60051     ESTABLISHED 3079/sshd: root@pts   
  16. tcp6       0      0 ::1:631                 :::*                    LISTEN      1286/cupsd            
  17. tcp6       0      0 :::5432                 :::*                    LISTEN      3985/postmaster       
  18. tcp6       0      0 ::1:25                  :::*                    LISTEN      1495/master           
  19. tcp6       0      0 ::1:6010                :::*                    LISTEN      3079/sshd: root@pts   
  20. tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd             
  21. tcp6       0      0 :::21                   :::*                    LISTEN      1311/vsftpd           
  22. tcp6       0      0 :::22                   :::*                    LISTEN      1290/sshd             
moonrong
  • 版权声明:本站原创文章,于2020年6月20日22:07:19,由 发表,共 2761 字。
  • 版权声明: 本文由于2020年6月20日22:07:19 发表在 好派笔记,共 2761 字。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: