在 CentOS 下使用 pgAdmin,通常有两种方式:
下面重点讲 CentOS 服务器上常用的 pgAdmin 4 Web 方式。
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/repo/pgdg-redhat-repo-latest.noarch.rpm
(CentOS 7 用 yum,CentOS 8/Stream 用 dnf)
sudo dnf install -y pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
会提示你:
sudo systemctl restart httpd
sudo systemctl enable httpd
(pgAdmin 4 默认通过 Apache 提供 Web 服务)
在浏览器中打开:
http://服务器IP/pgadmin4
例如:
http://192.168.1.100/pgadmin4
使用刚才设置的邮箱和密码登录。
local-pg)127.0.0.1 或数据库 IP5432postgres检查:
sudo systemctl status httpd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
systemctl status postgresql
postgresql.conf 中:listen_addresses = '*'
pg_hba.conf 允许访问仅适合有 GUI 的 CentOS:
sudo dnf install pgadmin4
然后命令行启动:
pgadmin4
✅ 服务器环境:pgAdmin 4 Web
✅ 本地开发:桌面版或 Windows / macOS 客户端
✅ 生产环境:建议限制 IP + HTTPS
如果你告诉我:
我可以给你更精确的步骤。