前言
文章主要介绍以下三方面:
- Centos8如何源码编译安装PostgreSQL
- 如何初始化PG数据库
- 如何用外部客户端,例如navicat连接pg数据库
录制了视频教程,上传至B站,链接 https://www.bilibili.com/video/BV14R4y1w7FV/
文档
文档链接 https://www.postgresql.org/docs/14/index.html
安装
- 编译
yum install make gcc
yum intall readline-devel
yum intall zlib-devel
make -j 4
make install
- 初始化pg数据库
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres.postgres /usr/local/pgsql/data
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
- 配置外部连接pg数据库
- 设置密码
/usr/local/pgsql/bin/psql
\password
- 修改listen_address 为 *
vim /usr/local/pgsql/data/postgres.conf
- 设置pg_hba.conf
# 增加以下
host all all 0.0.0.0/0 md5
- 重启数据库
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile restart
至此就可以用navicat等其它客户端或者后端开发人员连接数据库使用。