美文网首页
Centos7.6安装PostgreSQL12.1

Centos7.6安装PostgreSQL12.1

作者: laichj | 来源:发表于2019-11-26 00:30 被阅读0次

安装步骤

  1. 安装RPM
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  1. 安装客户端
yum install postgresql12
  1. 安装服务端
yum install postgresql12-server

配置步骤

  1. 始化数据库并启用自动启动 (可选)
# 初始化数据库
/usr/pgsql-12/bin/postgresql-12-setup initdb

# 设置开机启动pg服务
systemctl enable postgresql-12

# 启动pg服务
systemctl start postgresql-12
  1. 修改PostgreSQL远程连接配置
    vim /var/lib/pgsql/12/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
#host    all             all             127.0.0.1/32            ident
host    all             all             127.0.0.1/32            trust
host    all             all             all                     md5
# IPv6 local connections:
#host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     all                                     peer
host    replication     all             127.0.0.1/32            trust
host    replication     all             all                     md5
  1. 放开远程连接ip限制
    vim /var/lib/pgsql/12/data/postgresql.conf
# - Connection Settings -

listen_addresses = '*'          # what IP address(es) to listen on;

修改账号密码

  1. 修改postgres账号密码
  • 使用postgres登入数据库
psql -h 127.0.0.1 -d postgres -U postgres
  • 修改postgres密码
alter user postgres with password 'postgres';

相关文章

网友评论

      本文标题:Centos7.6安装PostgreSQL12.1

      本文链接:https://www.haomeiwen.com/subject/hopswctx.html