Linux安装postgresql

官网下载压缩包,地址:下载

  1. 将下载好的压缩包放至服务器,解压
tar -zxvf postgresql
  1. 进入解压后的文件夹
cd postgresql
  1. 运行configure
./configure

如果这一步报了这个错,说明系统已经安装了readline包
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn’t looking in the proper directory.
Use --without-readline to disable readline support.
 
可以运行一下这个命令,看看是不是这个包的问题
yum -y install -y readline-devel

重新 ./configure

又出现了一个类似的错误
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure. It is possible the compiler isn’t looking in the proper directory.
Use --without-zlib to disable zlib support.
 
运行下面的命令
yum install zlib-devel

再来一次 ./configure
成功。

make
make install
  1. 配置环境变量
#配置环境变量前先创建一个文件夹
mkdir /usr/local/pgsql/data
vim ~/.bash_profile

#写入以下配置
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data 
  1. 保存退出后执行命令,使配置生效
source ~/.bash_profile
  1. 创建一个普通用户
  2. 然后依次执行以下命令
chown postgres /usr/local/pgsql/data
cd /usr/local/pgsql/data
vi pg_hba.conf

#在host  all  all  127.0.0.1/32  trust 添加下面一行配置
   host  all  all  0.0.0.0/0     trust  #新增 
vi postgresql.conf
#放开注释并修改 
listen_addresses = '*'
#放开port注释
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
cd usr/local/pgsql/bin   
./pg_ctl start
#如果需要修改端口号,在安装目录的bin文件夹内,
vim postgresql.conf
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘水水

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值