美文网首页
CentOS 7 安装PostgreSQL

CentOS 7 安装PostgreSQL

作者: H_H_H_H_H | 来源:发表于2018-11-28 11:53 被阅读0次

1、安装yum源。
到Postgres官网,选择合适的版本,复制其链接
https://yum.postgresql.org/repopackages.php

2、以root模式进入CentOS 7,进行安装客户端

yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm  -->链接地址为第一步复制的地址

3、安装Postgres

yum install -y postgresql96-server postgresql96-contrib 
#(如果使用其他版本的PostgreSQL则需要把其中的两个96换成对应的数字)

4、初始化数据库

/usr/pgsql-9.6/bin/postgresql96-setup initdb
#(如果使用其他版本的PostgreSQL则需要把其中的9.6和96换成对应的数字)

5、启动服务

systemctl start postgresql-9.6  #启动服务
systemctl enable postgresql-9.6  #设为开机自启 
#(如果使用其他版本的PostgreSQL则需要把其中的两个9.6换成对应的版本)

6、关闭防火墙

firewall-cmd --add-service=postgresql --permanent  #开放防火墙。 
firewall-cmd --reload  #重启防火墙。

7、修改默认密码

su postgres #切换postgres账户
psql -U postgres  #登录数据库
ALTER USER postgres with encrypted password '123456';  #修改数据库密码
\q  #退出登录的数据库
exit  #退出用户

8、配置远程访问,配置文件postgresql.conf、pg_hba.conf

vim /var/lib/pgsql/9.6/data/postgresql.conf
#listen_addresses字段改为*即为所有IP开放,多个IP用, (逗号+空格)隔开

vim /var/lib/pgsql/9.6/data/pg_hba.conf
#添加:host all all 0.0.0.0/0 md5
#如果想允许所有IPv4地址,则加入一行host all all 0.0.0.0/0 md5。IPv6方法类似。 

9、重启服务,测试访问

systemctl restart postgresql-9.6.service

相关文章

  • 目录

    centos7联网安装postgresql10

  • CentOS 7源码安装PostGIS

    本文认为已安装PostgreSQL9.6,安装步骤如 Centos7安装PostgreSQL9.6。注意,作者将P...

  • macrobase安装过程中的问题

    macrobase需要安装postgresql数据库环境本次安装环境centos7,在centos7环境下安装po...

  • PostgreSQL 数据库

    安装 使用 参考链接: How To Install and Use PostgreSQL on CentOS 7...

  • PostgreSQL入门

    PostgreSQL入门 centos7 安装 以下是centos7的配置过程,仅供参考。详细安装官网教程地址。 ...

  • linux下安装postgresql

    安装环境:Centos7 postgresql版本:9.6.3 安装方式:编译安装 下载 官网下载:https:/...

  • CentOS7下安装CDH6.1

    在CentOS7下安装CDH6.1 环境 CentOS 7.8CDH6.1PostgreSQL 安装步骤 1.Ce...

  • 在CentOS环境下安装postgresql

    本文涉及CentOS 7下PostgreSQL9.6的安装,访问配置及简单使用。 1. CentOS环境 查看Ce...

  • 安装postgresql+postgis

    安装postgresql+postgis centos7 环境下安装 1.安装源: 2.安装 3.查看是否安装成果...

  • CentOS 7 安装PostgreSQL

    1、安装yum源。到Postgres官网,选择合适的版本,复制其链接https://yum.postgresql....

网友评论

      本文标题:CentOS 7 安装PostgreSQL

      本文链接:https://www.haomeiwen.com/subject/hgsaqqtx.html