CentOS 到了7.x版本, PostgreSQL也来到了10.x版本. 前些天MySQL都直接跨到了8.0版本.

本文是一篇在CentOS 7.4上安装安装PostgreSQL 10.3 的教程. 本文发布于2018-04-28.

1. 切换到root用户:
sudo su
2. 把最新的rpm包添加到系统库:

PostgreSQL会为所有的Linux平台发布rpm包, 而且会比其他的的库更新的更快.
可以试试在浏览器输入 https://download.postgresql.org/pub 看会发现什么.

### CentOS 7 ###

# rpm -Uvh https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

### RHEL 7 ###

# rpm -Uvh https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm
3. 用 yum 安装PostgreSQL:
# yum install -y postgresql10-server postgresql10
4. 安装完成后, 初次使用前先进行初始化:
# /usr/pgsql-10/bin/postgresql-10-setup initdb

PostgreSQL文件默认放在路径: /var/lib/pgsql/10/data/

5. 启动PostgreSQL:
# systemctl start postgresql-10
6. 设置PostgreSQL自启动:
# systemctl enable postgresql-10
7. 查询PostgreSQL运行状态:
# systemctl status postgresql-10

会输出类似的信息:

● postgresql-10.service - PostgreSQL 10 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-10.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2018-04-27 18:03:08 CST; 21h ago
Docs: https://www.postgresql.org/docs/10/static/
Main PID: 14916 (postmaster)
CGroup: /system.slice/postgresql-10.service
├─14916 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
├─14920 postgres: logger process
├─14922 postgres: checkpointer process
├─14923 postgres: writer process
├─14924 postgres: wal writer process
├─14925 postgres: autovacuum launcher process
├─14926 postgres: stats collector process
└─14927 postgres: bgworker: logical replication launcher Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ systemd[1]: Starting PostgreSQL 10 database server...
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.762 CST [14916] LOG: listening on IPv4 address "127.0.0.1...t 5432
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.762 CST [14916] LOG: could not bind IPv6 address "::1": C...ddress
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.762 CST [14916] HINT: Is another postmaster already runni...retry.
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.764 CST [14916] LOG: listening on Unix socket "/var/run/p....5432"
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.767 CST [14916] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.777 CST [14916] LOG: redirecting log output to logging co...rocess
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ postmaster[14916]: 2018-04-27 18:03:08.777 CST [14916] HINT: Future log output will appear in di..."log".
Apr 27 18:03:08 iZbp144wg7yw6hrfyu76anZ systemd[1]: Started PostgreSQL 10 database server.
Hint: Some lines were ellipsized, use -l to show in full.

8. 再确认看看PostgreSQL是否运行在5432端口:

# netstat -antup | grep 5432

会有类似输出:

tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      14916/postmaster
9. 连接PostgreSQL服务器:

PostgreSQL会自动创建postgres用户, 创建数据库之前, 要用postgres用户或root用户登录并重置postgres用户密码.

# su -l postgres
10. 连接数据库, psql命令会激活PostgreSQL数据库终端:
$ psql

会输出下列说明连接进入了PostgreSQL数据库:

psql (10.3)
Type "help" for help. postgres=#
11. 重置postgres用户密码:
postgres=# \password

密码:postgresql

在CentOS 7 / RHEL 7安装PostgreSQL 10的更多相关文章

  1. 在 CentOS 7.2 上安装 ODOO 10 (2018-10-09 持续更新)

    在 CentOS 7.2 上安装 ODOO 10 更新系统 yum update 安装 EPEL 源 1 yum install -y epel-release 安装依赖组件 yum install ...

  2. 在CentOS或RHEL上安装Nux Dextop仓库

    介绍 Nux Dextop是类似CentOS.RHEL.ScientificLinux的第三方RPM仓库(比如:Ardour,Shutter等等).目前,Nux Dextop对CentOS/RHEL ...

  3. centos 6.4下安装postgresql 9.2

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

  4. CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境

    准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...

  5. CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库

    CentOS 7.4 如何安装 MariaDB 10.3.9 Stable 数据库 一.CentOS 7.4上卸载 Mariadb 数据库 1.查询所安装的MariaDB组件 [libin@VM_0_ ...

  6. CentOS 7.4 下面安装 jdk 10 的一点总结

    CentOS 7.4 下面安装 jdk 10 的一点总结 一.前期工作 1.检验系统原版本 [root@zck ~]# java -version java version "1.7.0_& ...

  7. Ubuntu下编译安装postgreSQL 10.5

    Ubuntu下编译安装postgreSQL 10.5 ubuntu 16.04 LTS系统postgreSQL 10.5 安装包准备 1.从PostgreSQL官网下载PostgreSQL的安装包 安 ...

  8. CentOS 7 64位 安装 PostgreSQL 9.2整理

    centos版本 LSB Version: :core-4.1-amd64:core-4.1-noarchDistributor ID: CentOSDescription: CentOS Linux ...

  9. CentOS 6.9下安装PostgreSQL

    操作系统:CentOS6.9_x64 PostgreSQL官方网址: https://www.postgresql.org/ 安装数据库 使用如下命令: yum install postgresql- ...

随机推荐

  1. JavaScript控制语句结构、函数部分

    HTML页面代码: <html> <head> <meta charset="UTF-8"> <title>HelloWorld&l ...

  2. python爬虫笔记之re.IGNORECASE

    re.IGNORECASE有什么用?re.IGNORECASE是什么意思?(原谅我抓下seo..) 这里自己总结下: re.IGNORECASE是compile函数中的一个匹配模式. re.IGNOR ...

  3. 洛谷 P1970 花匠

    题目描述 花匠栋栋种了一排花,每株花都有自己的高度.花儿越长越大,也越来越挤.栋栋决定把这排中的一部分花移走,将剩下的留在原地,使得剩下的花能有空间长大,同时,栋栋希望剩下的花排列得比较别致. 具体而 ...

  4. [分享] 一款极简单的 BaseEntity CRUD 方法

    前言 尝试过 ado.net.dapper.ef,以及Repository仓储,甚至自己还写过生成器工具,以便做常规CRUD操作. 它们日常操作不方便之处: 每次使用前需要声明,再操作: 很多人一个实 ...

  5. [HNOI2015]亚瑟王[期望DP]

    也许更好的阅读体验 \(\mathcal{Description}\) 给出\(n\)个技能,每个技能按输入顺序有\(p[i]\)的概率释放并造成\(d[i]\)的伤害.每轮游戏从前往后顺序查看每个技 ...

  6. 开源项目托管到GitHub上

    前提是安装了git客户端 1.进入你的GitHub账户 2.点击new repositories   创建一个新的项目 输入项目名和项目描述   3.复制该项目的https路径 4.找一个文件夹来存放 ...

  7. Python基础总结之第四天开始【格式化‘字符串’】(新手可相互督促)

    年薪20万... 字符串格式化: 先看小案例-------: a = 'hello,my name is %s,I like %s.'%('XiaoHong','football') #在字符串中,[ ...

  8. 从零开发一款自己的小程序UI组件库(一)

    写在前面:有开发过小程序的朋友肯定知道组件化开发的特性,高内聚与低耦合.使用已有的UI组件库,诸如:vantUI-weapp.minUI-weapp等UI组件库的诞生使我们的开发速度大大的加快,丰富的 ...

  9. GCD和扩展GCD

    gcd(a, b)用于求解自然数a,b的最大公约数 int gcd(int a, int b) { ) return a; return gcd(b, a%b); } extgcd(a, b, x, ...

  10. jquery插件——仿新浪微博限制输入字数的textarea

    内容链接地址:http://www.cnblogs.com/jone-chen/p/5213851.html: <!DOCTYPE html> <html> <head& ...