1登录官网下载
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf -qy module disable postgresql
#安装
dnf install -y postgresql15-server
2安装配置
#初始化和启动
/usr/pgsql-15/bin/postgresql-15-setup initdb
systemctl enable postgresql-15
systemctl start postgresql-15
#配置
vim /var/lib/pgsql/15/data/postgresql.conf
#listen_addresses = 'localhost'-->listen_addresses = '*'
#配置允许远程访问
vim /var/lib/pgsql/15/data/pg_hba.conf
host all all 0.0.0.0/0 md5
#默认密码空,更改密码
[root@localhost data]# sudo -u postgres psql
psql (15.6)
Type "help" for help.
postgres=# ALTER USER postgres PASSWORD '密码';
ALTER ROLE
postgres=# \q
# 增加防火墙端口
firewall-cmd --add-port=5432/tcp --permanent
firewall-cmd --reload
systemctl restart postgresql-15
#测试远程连接
使用psql命令行工具或其他PostgreSQL客户端连接到数据库.
psql -h (ip) -d postgres -U postgres -p 5432