安装PostgreSQL到CentOS(YUM)
运行环境
系统版本: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)的更多相关文章
- Ejabberd2:安装和操作指南(centos yum 安装ejabberd)
(1)首先安装EPEL Repository ## RHEL/CentOS 6 32-Bit ## # wget http://download.fedoraproject.org/pub/ ...
- Linux CentOS安装postgresql 9.4
一.前言 PostgreSQL通常也简称Postgres,是一个关系型数据库管理系统,适用于各种Linux操作系统.Windows.Solaris.BSD和Mac OS X.PostgreSQL遵循P ...
- PostgreSQL 在centos 7下的安装配置
安装postgresql: sudo yum install postgresql-server 初始化数据库: sudo postgresql-setup initdb 启动数据库: sudo sy ...
- Centos7 yum安装postgresql 9.5
添加RPM yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos ...
- centos 6.4下安装postgresql 9.2
我的linux版本是centos 6.4 ,准备安装postgresql 9.2 根据官方说明: http://www.postgresql.org/download/linux/redhat/ 缺省 ...
- postgresql数据库的yum安装方法
实验环境>>>>>>>>>>>>>>>>>>操作系统:CentOS release 6.3 ...
- 在CentOS上编译安装PostgreSQL
http://my.oschina.net/tashi/blog 第一步:准备阶段 获取必需软件包: CentOS中查看是否安装了某个软件的命令:rpm -qa | grep 软件名.which命令可 ...
- Centos 7 安装 PostgreSQL
本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...
- Centos 7 安装 PostgreSQL PGAdmin4
本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...
随机推荐
- 从CSS盒子模型说起
前言 总括: 对于盒子模型,BFC,IFC和外边距合并等概念和问题的总结 原文地址:从CSS盒子模型说起 知乎专栏:前端进击者 博主博客地址:Damonare的个人博客 为学之道,莫先于穷理:穷理之要 ...
- Json学习笔记、思维导图
- C#编写程序,找一找一个二维数组中的鞍点
编写程序,找一找一个二维数组中的鞍点(即该位置上的元素值在行中最大,在该列上最小.有可能数组没有鞍点).要求: 1.二维数组的大小.数组元素的值在运行时输入: 2.程序有友好的提示信息. 代码: us ...
- C#编写一个控制台应用程序,输入三角形或者长方形边长,计算其周长和面积并输出
编写一个控制台应用程序,输入三角形或者长方形边长,计算其周长和面积并输出. 代码: using System; using System.Collections.Generic; using Syst ...
- 自定义View的onDraw 函数不执行
解决办法: 在自定义的View 的构造方法中添加一句话: this.setWillNotDraw(false);解释:那么加这条语句的作用是什么?先看API: If this ...
- Eclipse的视窗和视图概述、Eclipse工作空间的基本配置
Eclipse的视窗和视图概述视窗 每一个基本的窗体被称为视窗 * PackageExplorer 显示项目结构,包,类,及资源 * Outline 显示类的结构,方便查找,识别,修改 * C ...
- 在tomcat布置项目
1.将项目打成war包复制到tomcat-webapps 2.修改tomcat端口号 3.指定jdk 一.找到tomcat目录/bin 文件夹下的 catalina.bat文件 二.在文件中找到 ec ...
- 利用css3渐变效果实现圆环旋转效果
* { margin: 0; padding: 0; } .stage { width: 200px; height: 130px; margin: 100px auto; position: rel ...
- PostgreSQL执行计划:Bitmap scan VS index only scan
之前了解过postgresql的Bitmap scan,只是粗略地了解到是通过标记数据页面来实现数据检索的,执行计划中的的Bitmap scan一些细节并不十分清楚.这里借助一个执行计划来分析bitm ...
- 一. 为什么要用SpringMVC框架
以前是怎么做项目的.CoreServlet,起到一个中心处理器作用.所有的请求到服务器,服务器给CoreServlet,在里面处理所有表的增删改查,跳转也在里面做.以前做部门就是 DepServlet ...