PostgreSQL 11源码安装

本文详细介绍了在RedHat7.0Linux64bit环境下,通过源码方式安装PostgreSQL11的过程,包括环境准备、用户创建、编译安装及数据库初始化等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PostgreSQL 11源码安装

测试环境:RedHat 7.0 Linux 64bit

PostgreSQL 11源码安装包下载地址link

系统环境准备

RedHat 7.0默认会安装相关系统包,还需要增加PostgreSQL编译时必须包,如下:

gcc, bison, gcc-c++, readline, readline-devel, zlib, zlib-devel, perl, perl-devel

创建postgres用户,并创建安装目录


useradd Postgres

mkdir -p /opt/pgsql/data
chown -R postgres:postgres /opt/pgsql 

安装PostgreSQL

解压、编译、安装

tar -zxvf postgresql-11.1.tar.gz
cd postgresql-11.1
./configure --prefix=/opt/pgsql
make & make install

初始化数据库

su - postgres

[postgres@postgresql bin]$cd /opt/pgsql/bin
[postgres@postgresql bin]$ ./initdb -D /opt/pgsql/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /opt/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    ./pg_ctl -D /opt/pgsql/data/ -l logfile start


[postgres@postgresql bin]$./pg_ctl -D /opt/pgsql/data -l logfile start
waiting for server to start.... done
server started

#配置用户环境变量文件.bash.profile增加如下内容
export PATH=$PATH:/opt/pgsql/bin


[postgres@postgresql ~]$ psql
psql (11.1)
Type "help" for help.

postgres=#
postgres=#
postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

postgres=#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值