postgresql14源码安装

1.创建用户

useradd postgres

2.创建安装目录和日志目录

[root@localhost postgresql-14.4]# mkdir -p /home/pgsql/{data,log}

[root@localhost postgresql-14.4]# touch /home/pgsql/log/postgresql.log

[root@localhost pgsql]# chown -R postgres:postgres /home/pgsql/data

[root@localhost pgsql]# chown -R postgres:postgres /home/pgsql/log3

3.安装依赖包

[root@localhost ~]# rpm -ivh ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm

准备中...                          ################################# [100%]

正在升级/安装...

   1:ncurses-devel-5.9-14.20130511.el7################################# [100%]

[root@localhost ~]# rpm -ivh readline-devel-6.2-11.el7.x86_64.rpm

准备中...                          ################################# [100%]

正在升级/安装...

   1:readline-devel-6.2-11.el7        ################################# [100%]

[root@localhost ~]# rpm -ivh zlib-1.2.7-18.el7.x86_64.rpm --nodeps --force

准备中...                          ################################# [100%]

正在升级/安装...

   1:zlib-1.2.7-18.el7                ################################# [100%]

[root@localhost ~]# rpm -ivh zlib-devel-1.2.7-18.el7.x86_64.rpm

准备中...                          ################################# [100%]

正在升级/安装...

   1:zlib-devel-1.2.7-18.el7          ################################# [100%]

4.解压,编译安装

[root@localhost ~]# tar -xzvf postgresql-14.4.tar.gz

[root@localhost ~]# cd postgresql-14.4/

[root@localhost postgresql-14.4]# ./configure --prefix=/home/pgsql

[root@localhost postgresql-14.4]# make

[root@localhost postgresql-14.4]#make install

5.配置环境变量

[root@pg1 ~]# vim /etc/profile

export PGHOME=/home/pgsql/

export PGUSER=postgres

export PGPORT=5432

export PGDATA=/home/pgsql/data

export PGLOG=/home/pgsql/log/postgresql.log

export PATH=$PGHOME/bin:$PATH:$HOME/bin

export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH

[root@pg1 log]# source /etc/profile

6.初始化数据库

[root@localhost pgsql]# su - postgres

[postgres@localhost ~]$ /home/pgsql/bin/initdb -D /home/pgsql/data

7.修改配置文件

[postgres@localhost ~]$ vim /home/pgsql/data/pg_hba.conf

postgresql14源码安装_第1张图片

[postgres@localhost ~]$ vim /home/pgsql/data/postgresql.conf

postgresql14源码安装_第2张图片

 

8.启动数据库并修改密码

##启动数据库

[postgres@localhost ~]$ /home/pgsql/bin/pg_ctl -D /home/pgsql/data -l logfile start

##登陆数据库

[postgres@localhost ~]$ /home/pgsql/bin/psql

psql (14.4)

Type "help" for help.

##修改数据库密码

[postgres@localhost ~]$ /home/pgsql/bin/psql -c "alter user postgres with password '123456'"

ALTER ROLE

 

你可能感兴趣的:(postgresql,数据库)