当前位置:   article > 正文

CentOS7中安装PostgreSQL_centos7安装postgresql

centos7安装postgresql

前言

本篇文章主要介绍的是如何在官网下载.tar.gz压缩包,CentOS7中安装PostgreSQL

下载压缩包

打开官网的下载页面 https://www.postgresql.org/ftp/source/,下载想要的版本
在这里插入图片描述
在这里插入图片描述

上传压缩包

通过xshell工具将压缩包上传到linux
在这里插入图片描述
使用命令解压 tar -zxvf postgresql-14.4.tar.gz
使用命令创建postgres用户 useradd postgres

安装依赖
yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++ openssl-devel cmake gcc* readline-devel
  • 1

创建文件夹 mkdir /opt/postgres
被文件夹用户权限 chown -R postgres:postgres /opt/postgres/

添加环境变量

使用命令编辑 vim /etc/profile
在末尾增加以下内容

export PATH=/opt/postgres/bin:$PATH
export PGHOME=/opt/postgres
export PGDATA=/opt/postgres/data/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGHOME/lib/
export PATH=$PGHOME/bin:$PATH:$HOME/bin
  • 1
  • 2
  • 3
  • 4
  • 5

在这里插入图片描述
重新编译该文件 source /etc/profile
在解压目录下检查环境 ./configure --prefix=/opt/postgres/ --with-python --with-libxml --with-libxslt
在这里插入图片描述
先执行 make ,再执行 make install 进行编译
执行 /opt/postgres/bin/initdb -D $PGDATA -E UTF8设置编码
修改配置 vim /opt/postgres/data/postgresql.conf

listen_addresses = ‘*’
port = 5432
  • 1
  • 2
启动pg

使用命令 pg_ctl start
在这里插入图片描述
使用命令进入数据库 psql -h 127.0.0.1 -d postgres -U postgres
设置密码 \password postgres
在这里插入图片描述

放行远程连接的ip

使用命令 vim /opt/postgres/data/pg_hba.conf
最后增加一行 host all all 192.168.0.0/16 md5
在这里插入图片描述

重启服务

pg_ctl restart
使用Navicat连接
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/410484
推荐阅读
相关标签
  

闽ICP备14008679号