參考:https://www.postgresql.org/download/linux/redhat/linux
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm
yum install postgresql10
yum install postgresql10-server
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10
修改密碼:sql
su postgres psql ALTER USER postgres WITH PASSWORD '123456'; \q su root
①、修改postgresql.conf
文件:數據庫
vi /var/lib/pgsql/10/data/postgresql.conf
將listen_addresses
前的#
去掉,並將 listen_addresses = 'localhost'
改爲 listen_addresses = '*'
;
②、修改客戶端認證配置文件pg_hba.conf,將須要遠程訪問數據庫的IP地址或地址段加入該文件。centos
vi /var/lib/pgsql/10/data/pg_hba.conf
將IPv4區下的127.0.0.1/32
修改成0.0.0.0/0
; 將ident修改成md5
③、重啓服務使設置生效ide
systemctl restart postgresql-10