postgresql centos安裝

參考:https://www.postgresql.org/download/linux/redhat/linux

 

  • Install the repository RPM:yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm
  • Install the client packages:yum install postgresql10
  • Optionally install the server packages:yum install postgresql10-server
  • Optionally initialize the database and enable automatic start:
  • /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

修改PostgresSQL數據庫配置實現遠程訪問

①、修改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
相關文章
相關標籤/搜索