下面按常见场景给你讲一下 pgAdmin 在 Linux 上的配置方法,以 pgAdmin 4 为主(目前主流版本)。
# 1. 安装依赖
sudo apt update
sudo apt install curl ca-certificates gnupg
# 2. 添加 pgAdmin 仓库
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/pgadmin.gpg
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/pgadmin.gpg] https://ftp.pgadmin.org/pub/pgadmin/pgadmin4/apt/ $(lsb_release -cs) pgadmin4" > /etc/apt/sources.list.d/pgadmin4.list'
# 3. 安装
sudo apt update
sudo apt install pgadmin4
如果你要在 Linux 服务器上跑 Web 版 pgAdmin:
sudo apt install pgadmin4-web
sudo /usr/pgadmin4/bin/setup-web.sh
按提示设置:
然后访问:
http://服务器IP/pgadmin4
sudo apt install pgadmin4-desktop
安装后直接在菜单中启动 pgAdmin 4。
/pgadmin4local-db)localhost 或数据库 IP5432postgrespostgres✅ 点击 Save
检查 postgresql.conf:
listen_addresses = '*'
检查 pg_hba.conf:
host all all 0.0.0.0/0 md5
修改后重启:
sudo systemctl restart postgresql
检查 Apache / Nginx:
sudo systemctl status apache2
确认防火墙:
sudo ufw allow 80
sudo /usr/pgadmin4/bin/reset-password.sh
✅ 安装
✅ 配置 PostgreSQL 允许连接
✅ pgAdmin 添加 Server
✅ Web / 桌面访问
如果你能告诉我:
我可以直接给你一套精准命令。