centos7通过rpm安装postgresql15

参考信息

安装方法:
https://zhuanlan.zhihu.com/p/382949731
https://www.cnblogs.com/jinanxiaolaohu/p/12965037.html

安装包下载地址:
https://yum.postgresql.org/packages/

安装包:

上传到服务器

安装

1
rpm -ivh postgresql14-libs-14.3-1PGDG.rhel7.x86_64.rpm
1
rpm -ivh postgresql14-14.3-1PGDG.rhel7.x86_64.rpm
1
rpm -ivh postgresql14-server-14.3-1PGDG.rhel7.x86_64.rpm

前三步安装正确,第四步出现错误

1
rpm -ivh postgresql14-contrib-14.3-1PGDG.rhel7.x86_64.rpm 

错误情况如下:

1
2
3
4
5
6
[root@localhost pg]# rpm -ivh postgresql14-contrib-14.3-1PGDG.rhel7.x86_64.rpm 
警告:postgresql14-contrib-14.3-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
错误:依赖检测失败:
libperl.so()(64bit) 被 postgresql14-contrib-14.3-1PGDG.rhel7.x86_64 需要
libpython3.6m.so.1.0()(64bit) 被 postgresql14-contrib-14.3-1PGDG.rhel7.x86_64 需要

错误解决

1
rpm -ivh postgresql14-contrib-14.3-1PGDG.rhel7.x86_64.rpm --nodeps

PG的使用

初始化db

切换用户

1
su postgres
1
./initdb -D /var/lib/pgsql/14/data/

PostgreSQL:启动与停止
http://blog.itpub.net/31490526/viewspace-2711965/

启动PG

在用户postgres下

1
cd /usr/pgsql-14/bin
1
./pg_ctl -D /var/lib/pgsql/14/data/ start

修改密码:

1
alter user postgres with password '123456';

关闭防火墙

1
firewall-cmd --add-port=5432/tcp --permanent
1
firewall-cmd --reload
1
firewall-cmd --list-port --permanent

配置远程访问

配置PostgreSQL允许远程连接的方法
https://blog.csdn.net/CirtusSoda/article/details/115293976

1
cd /var/lib/pgsql/14/data/

修改两个文件

1
vim pg_hba.conf

添加以下内容:

1
host all all 0.0.0.0/0 scram-sha-256

注: scram-sha-256 用于开启密码校验

1
vim postgresql.conf

添加以下内容:

找到“listen_addresses“参数后,设置listen_addresses = ‘*’,保存。


centos7通过rpm安装postgresql15
http://yuanql.top/2023/04/17/04_MySQL/centos7通过rpm安装postgresql15/
作者
Qingli Yuan
发布于
2023年4月17日
许可协议