运行环境

系统版本:CentOS Linux release 7.6.1810 (Core)

软件版本:postgresql-12

硬件要求:无

安装过程

1、安装YUM-PostgreSQL存储库

YUM-PostgreSQL存储库由PostgreSQL官方提供。

[root@localhost ~]# yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2、安装PostgreSQL12

[root@localhost ~]# yum -y install postgresql12 postgresql12-server

3、初始化数据库

[root@localhost ~]# /usr/pgsql-12/bin/postgresql-12-setup initdb

4、修改配置,监听所有网卡地址

这样其他主机也可以通过主网卡访问到PostgreSQL数据库,默认情况下如果不修改,则PostgreSQL只允许本地访问。

[root@localhost ~]# vi /var/lib/pgsql/12/data/postgresql.conf
listen_addresses = '*'
port = 5432

5、添加信任网段,允许其他主机访问

[root@localhost ~]# vi /var/lib/pgsql/12/data/pg_hba.conf
# 添加以下内容到文件尾部。
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
# 身份验证方法(METHOD):
# - md5 密码经过MD5加密后登陆到数据库,一般采用选择这种方式。
# - password 使用明文密码登陆到数据库。
# - trust 信任该主机,无需密码即可登陆到数据库。
# - ident 通过读取"pg_ident.conf"文件里面具有系统用户=数据库用户的映射关系,可以使用系统用户登陆到
# 数据库。

6、启动服务

[root@localhost ~]# systemctl enable postgresql-12
[root@localhost ~]# systemctl start postgresql-12
[root@localhost ~]# systemctl status postgresql-12
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-03-05 08:22:38 EST; 5s ago
Docs: https://www.postgresql.org/docs/12/static/
[root@localhost ~]# netstat -lnupt |grep postmaster
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 35219/postmaster
tcp6 0 0 :::5432 :::* LISTEN 35219/postmaster

7、配置环境变量

配置环境变量,使“psql”客户端命令可以再全局使用。

[root@localhost ~]# vi /etc/profile
# PostgreSQL
export POSTGRESQL_BIN="/usr/pgsql-12/bin/"
export PATH=$PATH:$POSTGRESQL_BIN
[root@localhost ~]# source /etc/profile

8、查看数据库版本

切换操作用户“postgres”,“postgres”用户是PostgreSQL的超级用户。

[root@localhost ~]# sudo -i -u postgres
-bash-4.2$ psql
psql (12.2)
Type "help" for help.
postgres=# SELECT version();
version
-------------------------------------------------------------------------------------------------------
PostgreSQL 12.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
(1 row)

9、查看数据库列表

postgres=# select pg_database.datname from pg_database;
datname
-----------
postgres
template1
template0

10、修改"postgres"用户密码

默认情况下"postgres"用户没有密码,我们需要给超级管理员一个密码。

postgres=# \password
Enter new password: XXX
Enter it again: XXX
postgres=# exit
-bash-4.2$ exit

11、使用Windows客户端连接到PostgreSQL数据库

PGAdmin是一个开源的免费PostgreSQL数据库连接工具。

官网:https://www.pgadmin.org/

安装PostgreSQL到CentOS(YUM)的更多相关文章

  1. Ejabberd2:安装和操作指南(centos yum 安装ejabberd)

    (1)首先安装EPEL Repository     ## RHEL/CentOS 6 32-Bit ##  # wget http://download.fedoraproject.org/pub/ ...

  2. Linux CentOS安装postgresql 9.4

    一.前言 PostgreSQL通常也简称Postgres,是一个关系型数据库管理系统,适用于各种Linux操作系统.Windows.Solaris.BSD和Mac OS X.PostgreSQL遵循P ...

  3. PostgreSQL 在centos 7下的安装配置

    安装postgresql: sudo yum install postgresql-server 初始化数据库: sudo postgresql-setup initdb 启动数据库: sudo sy ...

  4. Centos7 yum安装postgresql 9.5

    添加RPM yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos ...

  5. centos 6.4下安装postgresql 9.2

    我的linux版本是centos 6.4 ,准备安装postgresql 9.2 根据官方说明: http://www.postgresql.org/download/linux/redhat/ 缺省 ...

  6. postgresql数据库的yum安装方法

    实验环境>>>>>>>>>>>>>>>>>>操作系统:CentOS release 6.3 ...

  7. 在CentOS上编译安装PostgreSQL

    http://my.oschina.net/tashi/blog 第一步:准备阶段 获取必需软件包: CentOS中查看是否安装了某个软件的命令:rpm -qa | grep 软件名.which命令可 ...

  8. Centos 7 安装 PostgreSQL

    本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...

  9. Centos 7 安装 PostgreSQL PGAdmin4

    本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...

随机推荐

  1. 【译】HTML表单高级样式

    系列文章说明 原文 在本文中,我们将了解如何在HTML表单上使用CSS,为那些难于自定义的表单组件加以样式.如前文所述,文本框和按钮很适合使用CSS,而现在我们得来探索HTML表单样式的那些坑了. 在 ...

  2. Python窗口学习之使窗口变得更高清

    初学tkinter发现窗口并不像成熟软件那么清楚 在实例化window后加这一行代码 #使窗口更加高清 # 告诉操作系统使用程序自身的dpi适配 ctypes.windll.shcore.SetPro ...

  3. MapReduce在集群执行任务时报错:Initialization of all the collectors failed. Error in last collector was:java.lang.ClassCastException

    报错信息详细: Error: java.io.IOException: Initialization of all the collectors failed. Error in last colle ...

  4. webpack的安装 以及 问题 以及 作用

    参考链接: https://blog.csdn.net/Rnger/article/details/81086938     https://blog.csdn.net/qq_38111015/art ...

  5. js手机号隐藏中间四位

    var tel = "13122223333"; var reg = /^(\d{3})\d{4}(\d{4})$/; tel = tel.replace(reg, "$ ...

  6. phpshe xml注入

    *php商城系统 xml注入* **页面样式* *Xml原理参考:* https://www.cnblogs.com/20175211lyz/p/11413335.html *漏洞函数simplexm ...

  7. Spring-AOP动态代理技术(底层代码)

    1.JDK代理:基于接口的动态代理技术 目标对象必须有接口,目标对象有什么方法,目标接口就有什么方法, 运行期间基于接口动态生成代理对象,所以代理对象也就有目标对象同样的方法. 注意:以下代码只是底层 ...

  8. Go xmas2020 学习笔记 12、Structs, Struct tags & JSON

    12-Structs, Struct tags & JSON. Struct. Struct Gotcha. Anonymous Struct Type. Make the zero valu ...

  9. AcWing周赛43

    AcWing周赛43 题源:https://www.acwing.com/activity/content/1233/ 4314. 三元组 直接暴力做就是了,我一开始还在找规律..悲 我滴代码 #in ...

  10. ArcGIS使用技巧(五)——批量裁剪

    新手,若有错误还请指正! 最近用到了,所以记下来,用同一矢量范围裁剪多幅栅格数据.用到了ArcGIS中的迭代模型(图1): 图 1 首先,需要做一个准备工作,就是把需要裁剪的栅格数据放在同一数据库中( ...