yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7.2-x86_64/pgdg-centos96-9.6-3.noarch.rpm
yum
install -y
postgresql96-server postgresql96-contrib
3、初始化數據庫
1
|
/usr/pgsql-9 .5 /bin/postgresql95-setup initdb
|
4、設置開機自啓動
1
|
systemctl enable postgresql-9.5.service
|
5、啓動服務
1
|
systemctl start postgresql-9.5.service
|
6、查看版本
PostgreSQL 9.5安裝配置
1、修改用戶密碼
1
2
3
4
|
su - postgres
psql -U postgres
ALTER USER postgres WITH PASSWORD '123456'
\q
|
2、開啓遠程訪問
1
2
|
vi /var/lib/pgsql/9 .5 /data/postgresql .conf
修改 #listen_addresses = 'localhost' 爲 listen_addresses='*'
|
3、信任遠程連接
1
|
vi /var/lib/pgsql/9 .5 /data/pg_hba .conf
|
1
2
3
4
|
修改如下內容,信任指定服務器連接
# IPv4 local connections:
host all all 127.0.0.1 /32 ident
host all all 192.168.137.1 /32 (需要連接的服務器IP) trust
|
4、重啓服務
1
|
systemctl restart postgresql-9.5.service
|