CentOS7 安装postpreSql 12+ 最新版本

 

  1. Install the repository RPM:
    yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  2. Install the client packages:
    yum install postgresql12
  3. Optionally install the server packages:
    yum install postgresql12-server
  4. Optionally initialize the database and enable automatic start:
    /usr/pgsql-12/bin/postgresql-12-setup initdb
    systemctl enable postgresql-12
    systemctl start postgresql-12

    5.修改密码 

su - postgres
psql

效果:

 输入修改密码的命令:

 

ALTER USER postgres WITH PASSWORD '123456';
退出

退出:\q

备注其他:列出所有库\l  列出所有用户\du 列出库下所有表\d

6、默认情况下postgresql是不用密码不支持远程登录的。我们需要修改配置文件

修改配置

vi /var/lib/pgsql/12/data/pg_hba.conf

CentOS7 安装postpreSql 12+ 最新版本_第1张图片

修改后:

CentOS7 安装postpreSql 12+ 最新版本_第2张图片

保存退出

我们改远程访问

vi /var/lib/pgsql/12/data/postgresql.conf

CentOS7 安装postpreSql 12+ 最新版本_第3张图片

修改后的

CentOS7 安装postpreSql 12+ 最新版本_第4张图片

保存退出重启

systemctl restart postgresql-12

关闭防火墙

systemctl stop firewalld.service 

查看防火墙状态

systemctl status firewalld.service
 

 

你可能感兴趣的:(linux,postpreSql)