一、yum安裝
1凝果、安裝yum倉庫
# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2祝迂、安裝client、server
# yum install postgresql96
# yum install postgresql96-server
# rpm -qa|grep postgresql
postgresql96-9.6.16-2PGDG.rhel7.x86_64
postgresql96-libs-9.6.16-2PGDG.rhel7.x86_64
postgresql96-server-9.6.16-2PGDG.rhel7.x86_64
3器净、初始化數(shù)據(jù)庫
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
# systemctl enable postgresql-9.6
# systemctl start postgresql-9.6
4型雳、配置
注意:所有的配置文件修改都需要重啟數(shù)據(jù)庫
4.1、修改用戶名密碼
# su - postgres
-bash-4.2$ psql -U postgres
postgres=# alter user postgres with password 'postgres'
4.2、允許遠(yuǎn)程訪問
# vim /var/lib/pgsql/9.6/data/postgresql.conf
修改#listen_addresses = 'localhost' 為 listen_addresses='*'
4.3纠俭、信任遠(yuǎn)程服務(wù)器連接
# egrep -v "^$|*#" /var/lib/pgsql/9.6/data/pg_hba.conf
local all all peer
host all all 127.0.0.1/32 ident
host all all 192.168.0.0/16 trust
host all all ::1/128 ident
4.4沿量、修改數(shù)據(jù)目錄
# vim /var/lib/pgsql/9.6/data/postgresql.conf
data_directory = '/app_server/pgdata'
# mkdir /app_server/pgdata
# chown postgres postgres /app_server/pgdata
# chmod 700 /app_server/pgdata
# systemctl restart postgresql-9.6
二、rpm安裝
# centos7.5
url: https://yum.postgresql.org/9.6/redhat/rhel-7.5-x86_64/
# 自行下載安裝
# yum install -y ...
其他步驟如上喲冤荆!