环景:
Ubuntu 20.04.3-live-server
Postgresql 12.9
问题描述:
Postgresql 12.9如何配置允许远程连接
解决方案:
1.修改postgresql.conf配置文件
vim /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
2.编辑修改pg_hba.conf配置文件
vim /etc/postgresql/12/main/pg_hba.conf
#ipv4 local connetions
host all all 0.0.0.0/0 md5
MD5表示需密码验证,也可选trust,无需密码
3.重启数据库服务
service postgresql restart
查看状态
service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2022-02-15 14:43:32 CST; 3s ago
Process: 1255 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1255 (code=exited, status=0/SUCCESS)
4.本地连接测试