debian

pgAdmin在Debian上如何配置

小樊
46
2025-07-29 20:57:36
栏目: 智能运维

在Debian系统上配置pgAdmin的步骤如下:

安装pgAdmin

  1. 更新系统
sudo apt update
sudo apt upgrade
  1. 安装依赖
sudo apt install curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates
  1. 添加pgAdmin存储库
curl -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/(lsb_release -cs) pgadmin4 main" | sudo tee /etc/apt/sources.list.d/pgadmin4.lists
sudo apt update
  1. 安装pgAdmin
sudo apt install pgadmin4

配置pgAdmin

  1. 运行设置脚本
sudo /usr/pgadmin4/bin/setup-web.sh

按照屏幕上的说明设置主密码,然后通过浏览器访问 http://your-IP-address/pgadmin4 使用主密码登录。

  1. 配置PostgreSQL
sudo apt install postgresql postgresql-contrib
sudo systemctl status postgresql
  1. 配置pgAdmin4对外端口(可选):
  1. 配置pgAdmin4服务,以便对外自动启动:
sudo nano /etc/systemd/system/pgadmin4.service
[Unit]
Description=pgadmin4
After=network.target

[Service]
Type=simple
ExecStart=~/py_env/miniconda3/envs/pgadmin4/bin/pgadmin4
User=mili
Group=mili
WorkingDirectory=~/py_env/miniconda3/

[Install]
WantedBy=multi-user.target
sudo systemctl start pgadmin4
sudo systemctl enable pgadmin4
  1. 配置防火墙(如果防火墙启用):
sudo ufw allow 5050/tcp
sudo ufw enable
  1. 访问pgAdmin4 Web界面: 在浏览器中输入 http://your_server_ip:5050,使用之前创建的pgAdmin4用户邮箱和密码登录。

  2. 连接到PostgreSQL服务器

以上步骤应该可以帮助你在Debian系统上成功配置pgAdmin。如果在配置过程中遇到任何问题,请参考官方文档或寻求社区帮助。

0
看了该问题的人还看了