在 CentOS 上使用 pgAdmin(PostgreSQL 的图形化管理工具)一般有 两种方式:
下面我按 CentOS 7 / 8 / Stream 常见场景,给你一份实操指南。
sudo dnf install -y https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-1-1.noarch.rpm
(CentOS 7 用 yum 替代 dnf)
sudo dnf install -y pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
过程中会让你:
sudo systemctl enable httpd
sudo systemctl start httpd
浏览器打开:
http://服务器IP/pgadmin4
登录你刚才设置的邮箱和密码即可。
systemctl status postgresql
编辑:
/var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
编辑:
/var/lib/pgsql/data/pg_hba.conf
添加:
host all all 0.0.0.0/0 md5
重启:
systemctl restart postgresql
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
setsebool -P httpd_can_network_connect 1
先本地测试:
psql -U postgres
你也可以在 Windows / macOS 上安装 pgAdmin,直接连接 CentOS 上的 PostgreSQL,不需要在服务器装 pgAdmin。
如果你告诉我:
我可以给你更精确的步骤。