在 CentOS 上使用 pgAdmin(PostgreSQL 的图形化管理工具)通常有两种方式:
下面重点讲 pgAdmin 4 Web 模式在 CentOS 上的安装与使用。
sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm
sudo yum install -y pgadmin4-web
如果 CentOS 8+ 用 dnf:
sudo dnf install -y pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
执行时会让你:
完成后会自动配置 Apache。
sudo systemctl start httpd
sudo systemctl enable httpd
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
http://服务器IP/pgadmin4
使用刚才设置的邮箱和密码登录。
⚠️ 注意:
postgresql.confpg_hba.conf检查:
systemctl status httpd
journalctl -xe
sudo chown -R apache:apache /var/lib/pgadmin
sudo chown -R apache:apache /var/log/pgadmin
sudo /usr/pgadmin4/bin/pgadmin4-cli重置
如果你愿意,可以告诉我:
我可以给你更精确的一步到位命令。