postgresql.conf
找到配置文件目录
[root@test pgsql]# locate ostgresql.conf
/usr/pgsql-15/share/postgresql.conf.sample
/var/lib/pgsql/15/data/postgresql.conf
打开文件进行编辑
[root@test pgsql]# vim /var/lib/pgsql/15/data/postgresql.conf
#listen_addresses = 'localhost' # what IP address(es) to listen on;
改为
listen_addresses = '*' # what IP address(es) to listen on;
保存退出
pg_hba.conf
[root@test pgsql]# locate pg_hba.conf
/usr/pgsql-15/share/pg_hba.conf.sample
/var/lib/pgsql/15/data/pg_hba.conf
进行修改
[root@test pgsql]# vim /var/lib/pgsql/15/data/pg_hba.conf
找到这一行
host all all 127.0.0.1/32 ident
修改为
host all all 0.0.0.1/0 md5
保存后重启服务
[root@test pgsql]# systemctl restart postgresql-15