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

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

 

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

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值