1、yum安装postgres15.3

yum安装postgres15.3

1、选择安装的版本1.53

参考官网文档:https://www.postgresql.org/download/linux/redhat/

2、创建postgres用户

root用户执行

groupadd -g 15432 postgres
useradd -u 15432 -g postgres postgres
passwd postgres

3、执行yum安装命令

/usr/pgsql-15/bin/postgresql-15-setup是安装postgres路径

initdb是初始化postgres数据库

systemctl enable是开机启动

systemctl start是启动postgres

执行命令如下:

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
sudo yum install -y postgresql15-server
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15

系统会默认创建用户postgres,密码为空

sudo -i -u postgres

执行psql

[postgres@dbServer42 ~]$ psql
psql (15.3)
Type "help" for help.
postgres=#

说明安装成功。

4、修改配置文件

关闭服务:

sudo systemctl stop postgresql-15

4.1、修改postgresql.conf

vi /var/lib/pgsql/15/data/postgresql.conf

修改配置如下:

/+关键字查询

listen_addresses = '*'
port = 5432
max_connections = 1000
password_encryption = scram-sha-256
log_directory = '/u01/pgdata/log'

:wq保存

4.2、修改pg_hba.conf

vi /var/lib/pgsql/15/data/pg_hba.conf

修改配置如下:

增加0.0.0.0/0 开发对应ip的权限

# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
host all all 0.0.0.0/0 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
host replication all 0.0.0.0/0 scram-sha-256
posted @   站着说话不腰疼  阅读(852)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示