Debian中PostgreSQL网络配置要点如下:
/etc/postgresql/<版本>/main/postgresql.conf,将listen_addresses设为'*'(允许所有IP连接)或指定IP。/etc/postgresql/<版本>/main/pg_hba.conf,添加规则允许远程IP访问(如host all all 0.0.0.0/0 md5),推荐使用scram-sha-256替代md5增强安全性。sudo systemctl restart postgresql使配置生效。ufw,运行sudo ufw allow 5432/tcp开放默认端口;若用iptables,需添加对应规则。psql -h <服务器IP> -U <用户名> -d <数据库>测试远程连接,确保配置正确。listen_addresses='*',限制为特定IP。注:高版本Debian(如Bookworm)需注意网络配置文件路径可能为/etc/netplan/,但PostgreSQL配置路径不变。