与你相遇好幸运,CentOS 7 x86_64使用Yum安装PostgreSQL

时间:2023-12-19 14:48:02

访问http://yum.pgrpms.org/reporpms/repoview/letter_p.group.html,下载并安装和当前系统对应的rpm文件。

wget https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm

rpm -Uvh pgdg-centos95-9.5-3.noarch.rpm

cd /etc/yum.repos.d

vi CentOS-Base.repo

修改原始的yum仓库配置,在[base]和[updates]部分的尾部追加exclude=postgresql*用以取消从默认仓库安装和更新PostgreSQL。

yum install postgresql95-server.x86_64 -y

systemctl postgresql-9.5 initdb
systemctl status postgresql-9.5.service

su - postgres

psql

ALTER USER postgres WITH PASSWORD 'passwd'

\q

systemctl restart postgresql-9.5.service

vi /var/lib/pgsql/9.5/data/pg_hba.conf

修改客户端认证配置文件,将METHOD由默认的ident改为md5

systemctl restart postgresql-9.5.service

安装postgis

yum search postgis

yum -y install epel-release

yum install postgis2_95-client.x86_64 -y

Cheers !