1.添加prm安装源(或者从官网下载)

PostgreSQL官网地址:https://yum.postgresql.org/

yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

2.安装依赖包

yum install postgresql96-server postgresql96-contrib postgresql96-devel

3.检验是否安装成功

rpm -aq| grep postgres

4.创建数据库存放路径

[root@ecs-552a home]# mkdir -p /data/pg/data
[root@ecs-552a home]# chown -R postgres:postgres /data/pg
[root@ecs-552a home]# chown -R postgres:postgres /data/pg/data
[root@ecs-552a home]# chmod /data/pg/data

5.设置环境变量

PGDATA=/data/pg/data
PGHOST=127.0.0.1
PGDATABASE=postgres
PGUSER=postgres
PGPORT=
PATH=/usr/pgsql-9.6/bin:$PATH
export PATH
export PGDATA PGHOST PGDATABASE PGUSER PGPORT
export TMOUT=

配置生效

[root@ecs-552a home]# source /etc/profile

查看是否已经添加成功

[root@ecs-552a home]# export 

6.初始化数据库

[root@ecs-552a home]# su postgres  //切换用户
bash-4.2$ initdb -D /data/pg/data //初始化数据库
//或者执行
/usr/pgsql-9.6/bin/postgresql96-setup initdb -D /data/pg/data
exit //退出当前用户

7.查看安装目录

8.配置远程访问

修改配置文件1:/data/pg/data/pg_hba.conf

修改配置文件2:/data/pg/data/postgresql.conf

9.设置开机启动

修改文件: /usr/lib/systemd/system/postgresql-9.6.service

默认:
# Location of database directory
Environment=PGDATA=/var/lib/pgsql/9.6/data/ 修改为:
Environment=PGDATA=/data/pg/data/ 重启postgresql-.6服务,使配置文件重效
service postgresql-9.6 restart

10.开机自启动

systemctl enable postgresql-9.6.service

11.启动pgsql数据库

su postgres -c "/usr/pgsql-9.6/bin/pg_ctl start -D /data/pg/data"

ps -ef|grep postgres #查看相关进程

12.修改密码

postgres用户登录:
su postgres 连接数据库:
psql -U postgres 修改密码:
Alter user postgres with password '******'; 退出数据库连接:
\q

13.重启服务

14.开启防火墙端口

15.工具连接

或者使用网页:

卸载pgsql:

yum remove postgresql*

centos7 安装pgsql的更多相关文章

  1. centos7安装pgsql及操作命令

    1.下载所需要的数据库版本https://yum.postgresql.org/repopackages.php 2.安装数据库版本包 yum install -y https://download. ...

  2. HP服务器 hp 360g5 centos7安装问题

    HP服务器  hp 360g5 centos7安装问题 一 :启动盘无法识别硬盘 1.进入安装光盘,用上下键选择安装centos--Install Centos7(注意不可按Enter键),如图: 2 ...

  3. CentOS7 安装Mono及Jexus

    CentOS7安装Mono及Juxes 1 安装Mono 1.1 安装yum-utils 因为安装要用到yum-config-manager,默认是没有安装的,所以要先安装yum-utils包.命令如 ...

  4. CentOS7安装mysql提示“No package mysql-server available.”

    针对centos7安装mysql,提示"No package mysql-server available."错误,解决方法如下: Centos 7 comes with Mari ...

  5. CentOS7安装Oracle 11gR2 安装

    概述 Oracle 在Linux和window上的安装不太一样,公司又是Linux系统上的Oracle,实在没辙,研究下Linux下Oracle的使用,oracle默认不支持CentOS系统安装,所以 ...

  6. Centos7安装完毕后重启提示Initial setup of CentOS Linux 7 (core)的解决方法

    问题: CentOS7安装完毕,重新开机启动后显示: Initial setup of CentOS Linux 7 (core) 1) [x] Creat user 2) [!] License i ...

  7. centos7安装eclipse

    centos7安装eclipse Eclipse是一个集成开发环境(IDE),包含一个基工作区和定制环境的可扩展插件系统.大部分使用 Java 编写,Eclipse 可以用来开发应用程序.通过各种插件 ...

  8. CentOS7安装mongoDB数据库

    CentOS7安装mongoDB数据库 时间:2015-03-03 16:45来源:blog.csdn.net 作者:进击的木偶 举报 点击:8795次 mongoDB是目前发展比较好的NOSQL数据 ...

  9. CentOS7安装Ambari

    环境: CentOS7安装两个节点:master.slave1.并配置ssh无密码登录. 步骤: 获取 Ambari 的公共库文件(public repository): wget http://pu ...

随机推荐

  1. linux系统运维命令

    1.动态查看网卡流量  sar -n DEV 1 2.查看当前网卡的buffer size情况 ethtool -g eth0 3.修改当前网卡的buffer size ethtool -G eth0 ...

  2. python转换图片格式

    在图片所在的路径下,打开命令窗口 bmeps -c picturename.png picturename.eps

  3. 处理 Archlinux 报错

    failed to kernel 1 sudo pacman -S linux-headers tpm_crb, uvcvideo 等错误 sudo vim /etc/modprobe.d/black ...

  4. rpc轻量级框架实例

  5. java.lang.IllegalStateException: Connection pool shut down

    最近使用HttpClient 4.5 使用 CloseableHttpClient 发起连接后,使用CloseableHttpResponse 接受返回结果,结果就报错了,上网查了下,有位stacko ...

  6. Oracle SQL 部分特殊字符转义及escape的用法

    在处理sql时,遇到insert 或update 的参数中含有特殊字符“&”,下划线“_”, 单引号" ' "等时,要做转义处理. 例:插入特殊字元'&' upda ...

  7. Redis考察点解析

    目录 1. Redis数据结构 1. 常用数据结构 2. 高级数据结构 2. Redis分布式锁 1. Redis分布式锁原理 2. 如果在setnx之后执行expire之前进程意外crash或者要重 ...

  8. elasticsearch 之编译过程

    https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md 不同的版本需要指定JDK 可以下载openJDK版本到服务器上 ...

  9. PyAutoGUI使用

    PyAutoGUI是一个纯Python的GUI自动化工具,其目的是可以用程序自动控制鼠标和键盘操作,利用它可以实现自动化任务,再也不用担心有重复枯燥的任务了. 安装: pip install pyau ...

  10. Pocket Gem OA: Path Finder

    1. 有向图 找所有start node到end node之间的路径 输入是一个txt 形式如下: A E A : B C D. B : C C : E D : B. 输出一个List<Stri ...