统信UOS V20 离线安装PGSQL14.3
安装前准备
1、安装包、以及所需文件,文件下载地址回头重新编辑该文章附带地址或自行百度
2、将文件上传至服务器
开始安装
1、安装所有rpm
rpm -ivh --force --nodeps *.rpm
2、解压pgsql安装包到当前目录下
#进入到/usr/local/pgsql #根据个人情况调整
tar -xvf postgresql-14.3
3、创建安装目录以及数据存放目录
mkdir /home/pgsql #创建安装目录 根据个人调整
mkdir /home/pgsql/data #创建数据存放目录 根据个人调整
4、进入到解压后安装包目录开始安装PGSQL
cd /usr/local/pgsql/postgresql-14.3/ #进入安装包解压后的目录
#准备编译,指定安装目录,过滤readline报错
#这里一定要过滤这个报错,不影响后续安装以及使用!!!!
./configure --prefix=/home/pgsql --without-readline
#编译
make
#安装
make install
5、使用root用户开放权限
chown -R postgres:postgres /home/pgsql/data
chown -R postgres:postgres /home/pgsql
chmod -R 700 postgres:postgres /home/pgsql/data/
chmod -R 700 postgres:postgres /home/pgsql/
6、数据库初始化以及数据库状态
su - postgres #切换为pg用户
cd /home/pgsql/bin/ #进入bin目录
initdb -D /home/pgsql/data #初始化数据库
systemctl status postgresql #查看数据库状态
systemctl stop postgresql #停止数据库
systemctl start postgresql #启动数据库
7、数据库基础配置
#修改/home/pgsql/data/postgresql.conf文件
port = 5432 #端口
listen_addresses = '*' #监听所有IP
max_connections = 1000 #最大连接数
#修改/home/pgsql/data/pg_hba.conf文件
#所有主机都可以访问,根据需求配置
host all all 0.0.0.0/0 trust
#某个主机可以访问
#host all all 192.168.0.1/24 trust