CentOS7 yum安裝、配置PostgreSQL 9.5


PostgreSQL 9.5安裝

1、添加RPM

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

2、安裝PostgreSQL 9.5

yum install postgresql95-server postgresql95-contrib

3、初始化數據庫

/usr/pgsql-9.5/bin/postgresql95-setup initdb

4、設置開機自啟動

systemctl enable postgresql-9.5.service

5、啟動服務

systemctl start postgresql-9.5.service

6、查看版本

psql --version

 

PostgreSQL 9.5安裝配置

1、修改用戶密碼

su - postgres
psql -U postgres
ALTER USER postgres WITH PASSWORD '123456' 
\q

2、開啟遠程訪問

vi /var/lib/pgsql/9.5/data/postgresql.conf
修改#listen_addresses = 'localhost'  為  listen_addresses='*'

3、信任遠程連接

vi /var/lib/pgsql/9.5/data/pg_hba.conf
修改如下內容,信任指定服務器連接
# IPv4 local connections:
host    all            all      127.0.0.1/32      ident
host    all            all      192.168.137.1/32(需要連接的服務器IP)  trust

4、重啟服務

systemctl restart postgresql-9.5.service

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM