postgresql从入门到菜鸟(一)通过编译方式安装postgresql

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/s465689853/article/details/75043840

最近工作需要用到postgresql数据库,学习过程中发现网上的资料并不是很多。在这里把学习的过程以及学习过程中的问题分享出来,希望能对需要刚才开始学习postgresql的人有所帮助。

(一)安装篇

安装安装环境为:rehel虚拟机。

安装方式:源码安装。

postgresql版本:9.5.4.

首先下载postgresql源码包

wget https://ftp.postgresql.org/pub/source/v9.5.4/postgresql-9.5.4.tar.bz2

解压源码

扫描二维码关注公众号,回复: 4552852 查看本文章
tar -xjvf postgresql-9.5.4.tar.bz2 

进入文件夹下配置

cd postgresql-9.5.4/
./configure


如果出现以下错误,则说明没有安装依赖

checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found

安装依赖

yum install readline-devel
yum install zlib-devel

重新配置

./configure

配置后开始编译

make

编译后出现以下提示开始安装

All of PostgreSQL successfully made. Ready to install.

安装

 make install

新建数据库目标文件夹

mkdir /file/dbuser/ #路径与环境变量中PGDATA一致

添加环境变量

vi ~/.bash_profile


添加以下配置

PGDATA= /file/dbuser/
PATH=/usr/local/pgsql/bin:$PATH
export PGDATA PATH

添加用户(注:是系统用户不是数据库用户)

useradd postgres
passwd postgres 
#输入postgresql的密码


给新用户赋予权限

chown -R postgres /file/dbuser


初始化数据库

Initdb –d /file/dbuser


数据库启动

pg_ctl start -l /file/dbuser/db.log #-l用于指定日志文件,名称随意

猜你喜欢

转载自blog.csdn.net/s465689853/article/details/75043840
今日推荐