CentOS 7.5安裝PostgreSQL10.5

背景介紹:sql

如今用MySQL數據庫的不少,但PostgreSQL的確比較少,下面介紹用yum在CentOS 7.5安裝PostgreSQL10.5。數據庫

1. PostgreSQL 10使用yum存儲庫,請按照下列步驟操做:
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpmvim

若是是PostgreSQL9的話:服務器

yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7.5-x86_64/pgdg-redhat96-9.6-3.noarch.rpmpost

 

2. 安裝服務器軟件包:postgresql

postgresql10安裝:
yum install postgresql10-serverorm

postgresql9安裝:server

yum install postgresql96-serverblog

 

安裝客戶端軟件包:
yum install postgresql10it

yum install postgresql96

 

3. 可選地初始化數據庫並啓用自動啓動:
/usr/pgsql-10/bin/postgresql-10-setup initdb

/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl enable postgresql-10

systemctl enable postgresql-9.6
systemctl start postgresql-10

systemctl start postgresql-9.6

 

4. 配置用戶名密碼:
PostgreSQL登陸
#sudo -u postgres psql 
postgres=# ALTER USER postgres WITH PASSWORD 'postgres';
postgres=#\q
# sudo passwd -d postgres

 

5. 配置遠程訪問

查看pg_hba.conf的路徑:
su - postgres -c "psql -t -P format=unaligned -c 'show hba_file'"


#vim /var/lib/pgsql/10/data/pg_hba.conf

#vim /var/lib/pgsql/9.6/data/pg_hba.conf
host    all     all             0.0.0.0/0               trust
#vim /var/lib/pgsql/10/data/postgresql.conf

#vim /var/lib/pgsql/9.6/data/postgresql.conf 
listen_addresses = '*'

相關文章
相關標籤/搜索