centos

CentOS 上如何安装 PGAdmin

小樊
89
2025-02-09 04:03:24
栏目: 智能运维

要在 CentOS 上安装 PGAdmin,请按照以下步骤操作:

  1. 首先,确保系统已更新并安装了必要的依赖项。打开终端并运行以下命令:
sudo yum update
sudo yum install -y wget
  1. 下载 PGAdmin 安装包。访问 PGAdmin 官方网站(https://www.pgadmin.org/download/ )以获取最新版本的下载链接。在本示例中,我们将下载 PGAdmin 4 的 RPM 包。使用 wget 命令下载:
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.26/linux-x86_64/pgadmin4-4.26-linux-x86_64.tar.gz

请注意,上述链接和版本可能会随着时间的推移而发生变化。请确保下载适用于您的系统的最新版本。

  1. 解压下载的安装包:
sudo tar -xvf pgadmin4-4.26-linux-x86_64.tar.gz
  1. 将解压后的 pgAdmin 目录移动到合适的路径,例如 /opt
sudo mv pgadmin4 /opt
  1. 创建一个名为 pgadmin 的系统用户和组:
sudo groupadd pgadmin
sudo useradd -M -r -g pgadmin pgadmin
  1. 更改 pgAdmin 目录的所有权:
sudo chown -R pgadmin:pgadmin /opt/pgadmin4
  1. 创建一个名为 pgadmin.conf 的配置文件:
sudo nano /etc/sysconfig/pgadmin4

在文件中添加以下内容:

# Path to the PostgreSQL server
PGADMIN_SERVER_HOST=localhost
# Port number of the PostgreSQL server
PGADMIN_SERVER_PORT=5432
# Name of the database to connect to
PGADMIN_DATABASE=postgres
# Username and password for the PostgreSQL server
PGADMIN_USERNAME=postgres
PGADMIN_PASSWORD=your_password

your_password 替换为您的 PostgreSQL 用户密码。

  1. 重启 pgAdmin 服务:
sudo systemctl restart pgadmin4
  1. 设置开机启动:
sudo systemctl enable pgadmin4
  1. 打开浏览器并访问 http://your_server_ip:80,其中 your_server_ip 是您的 CentOS 服务器的 IP 地址。使用您在步骤 7 中设置的 PostgreSQL 凭据登录。

现在,您已经在 CentOS 上成功安装了 PGAdmin 并可以开始管理您的 PostgreSQL 数据库了。

0
看了该问题的人还看了