centos7 postgres源码安装

postgresql源码安装

下载postgresql源代码,使用wget命令从官网下载源码

zhangliang[root@localhost ~/package]# wget --no-check-certificate https://ftp.postgresql.org/pub/source/v14.7/postgresql-14.7.tar.gz

解压源码,ls确认安装包已经下载完毕了可以进行解压

zhangliang[root@localhost ~/package]# tar zxvf postgresql-14.7.tar.gz

配置编译

zhangliang[root@localhost ~/package]# cd postgresql-14.7/
zhangliang[root@localhost ~/package/postgresql-14.7]# ./configure
zhangliang[root@localhost ~/package/postgresql-14.7]# make

安装

zhangliang[root@localhost ~/package/postgresql-14.7]# make install

创建用户

zhangliang[root@localhost ~/package/postgresql-14.7]# useradd postgres

创建data目录

zhangliang[root@localhost ~/package/postgresql-14.7]# mkdir /usr/local/pgsql/data
zhangliang[root@localhost ~/package/postgresql-14.7]# chown postgres /usr/local/pgsql/data

配置环境变量

zhangliang[root@localhost ~]# su - postgres
zhangliang[postgres@localhost ~]$ vi .bash_profile

添加如下配置

export PATH=/usr/local/pgsql/bin:$PATH
export PGDATA=/usr/local/pgsql/data
export PGPORT=5432

生效配置
zhangliang[postgres@localhost ~]$ . .bash_profile

创建数据库

zhangliang[postgres@localhost ~]$ initdb -D /usr/local/pgsql/data
zhangliang[postgres@localhost ~]$ pg_ctl -D /usr/local/pgsql/data -l logfile start
zhangliang[postgres@localhost ~]$ createdb test

验证

zhangliang[postgres@localhost ~]$ psql test
psql (14.7)
Type "help" for help.

test=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 14.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)

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