Linux 编译安装 PostgreSQL 12.2

PostgreSQL Linux About 1,080 words

下载地址

清华大学镜像,下载并解压。

wget https://mirrors.tuna.tsinghua.edu.cn/postgresql/source/v12.2/postgresql-12.2.tar.gz

tar -zxvf postgresql-12.2.tar.gz

安装依赖

Ubuntu

apt-get install libreadline-dev
apt-get install libxslt-dev

CentOS

yum install libxslt-devel

配置编译参数

./configure --prefix=/usr/local/pgsql --with-libxml --with-libxslt
make
make install

可能错误

configure: error: library 'xslt' is required for XSLT support

configure: error: readline library not found

安装readline

yum install readline-devel

创建启动用户

useradd postgres
groupadd postgres

修改数据库文件所属

chown -R postgres:postgres /usr/local/pgsql

修改数据存储文件夹所属

mkdir /usr/local/pgsql/data
chown -R postgres:postgres /usr/local/pgsql/data

初始化数据库并指定存储路径

initdb -D /usr/local/pgsql/data

启动 PostgreSQL 且生成日志文件 logfile

/usr/local/pgsql/bin目录下执行。

./pg_ctl -D /usr/local/pgsql/data -l logfile start

停止 PostgreSQL

./pg_ctl -D /usr/local/pgsql/data -l logfile stop

重启 PostgreSQL

./pg_ctl -D /postgresql/pgsql/data/ -l logfile restart

备注

PostgreSQL 13.2Ubuntu 14.04下指定--with-libxml未生效。

参考

https://www.postgresql.org/docs/current/install-procedure.html

Views: 2,017 · Posted: 2021-05-15

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh