在 CentOS 上远程使用 pgAdmin 连接 PostgreSQL,一般有两种常见方式:
sudo dnf install -y https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
sudo dnf install -y pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
按提示设置:
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
http://服务器IP/pgadmin4
编辑:
sudo vi /var/lib/pgsql/15/data/postgresql.conf
(版本号可能不同)
修改:
listen_addresses = '*'
编辑:
sudo vi /var/lib/pgsql/15/data/pg_hba.conf
添加:
host all all 0.0.0.0/0 md5
sudo systemctl restart postgresql-15
sudo firewall-cmd --add-port=5432/tcp --permanent
sudo firewall-cmd --reload
如果你用的是 CentOS 7 / 8 / Stream 或 特定 PostgreSQL 版本,可以告诉我,我可以给你精确命令。