PostgreSQL 10.12 安装系列 - Yum+rpm 安装

来源:这里教程网 时间:2026-03-14 19:46:02 作者:

Yum仓库下载: https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm 安装yum仓库:

[root@open_source ~]# ls
anaconda-ks.cfg  
pgdg-redhat-repo-latest.noarch.rpm
[root@open_source ~]# rpm -ivh pgdg-redhat-repo-latest.noarch.rpm 
warning: pgdg-redhat-repo-latest.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:pgdg-redhat-repo-42.0-6          ################################# [100%]
   
 
[root@open_source ~]# ls -rtl /etc/yum.repos.d/pgdg-redhat-all.repo 
-rw-r--r-- 1 root root 5904 Sep 27 09:04 /etc/yum.repos.d/pgdg-redhat-all.repo

通过yum安装数据库:

[root@open_source ~]# yum install -y postgresql10
[root@open_source ~]# yum install postgresql10-server

  初始化数据库:

[root@open_source ~]# /usr/pgsql-10/bin/postgresql-10-setup initdb

  配置开启启动:

[root@open_source ~]# systemctl enable postgresql-10

  启动数据库:

[root@open_source ~]# systemctl start postgresql-10

  不限制任何主机并允许远程登陆:

[root@open_source ~]# vi /var/lib/pgsql/10/data/postgresql.conf
修改listen_addresses = ‘*’

  修改pg.hba文件需要重启服务:

[root@open_source ~]# vim /var/lib/pgsql/11/data/pg_hba.conf
添加   host   all     all     0.0.0.0/0   md5

相关推荐