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
相关文章
相关标签/搜索