官网
PostgreSQL: The world's most advanced open source database
安装教程
PostgreSQL: Linux downloads (Red Hat family)
server_ip=192.168.132.134
pwd=zenglg
# 下载链接,附带安装指令 https://www.postgresql.org/download/linux/redhat/
# 官网 https://www.postgresql.org/
# 安装
dnf install postgresql-server -y
# 初始化数据库
postgresql-setup --initdb
# 设置开机自启
systemctl enable postgresql.service
# 启动数据库
systemctl start postgresql.service
# 打开数据库存储配置文件存储路径,
cd /var/lib/pgsql/data
# 修改 postgresql.conf
sed -i '63s/#port = 5432/port = 5432/' /var/lib/pgsql/data/postgresql.conf
sed -i '59s/#listen_addresses/listen_addresses/' /var/lib/pgsql/data/postgresql.conf
sed -i '59s/localhost/*/' /var/lib/pgsql/data/postgresql.conf
# 修改pg_hba.conf
sed -i '82s/127.0.0.1/'$server_ip'/' /var/lib/pgsql/data/pg_hba.conf
# 取消客户端密码登录
sed -i '82s/ident/trust/' /var/lib/pgsql/data/pg_hba.conf
#在82行后面增加一行内容 host all all 0/0 trust
sed -i 'N;82 a host all all 0/0 trust' /var/lib/pgsql/data/pg_hba.conf
# 重启服务,配置之后需要重启服务才能生效
systemctl restart postgresql.service
# 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service