您当前的位置: 首页 >  sql

Bulut0907

暂无认证

  • 4浏览

    0关注

    346博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Centos7安装和配置PostgreSQL13

Bulut0907 发布时间:2021-07-23 14:34:54 ,浏览量:4

目录
  • 1. 安装PostgreSQL
  • 2. 修改密码
  • 3. 配置远程访问

1. 安装PostgreSQL
[root@canal3 ~]#
[root@canal3 ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
[root@canal3 ~]#
[root@canal3 ~]# yum install -y postgresql13-server
[root@canal3 ~]#
[root@canal3 ~]# /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

[root@canal3 ~]#
[root@canal3 ~]# systemctl start postgresql-13
[root@canal3 ~]# 
2. 修改密码

安装自动在centos上创建无密码的用户postgres, 和在postgresql中创建超级用户postgres

[root@canal3 opt]# 
[root@canal3 opt]# su postgres
bash-4.2$ 
bash-4.2$ psql
psql (13.3)
输入 "help" 来获取帮助信息.

postgres=# 
postgres=# alter user postgres with password 'postgres123';
ALTER ROLE
postgres=# 
3. 配置远程访问

在/var/lib/pgsql/13/data/postgresql.conf修改以下内容

listen_addresses = '*'

在/var/lib/pgsql/13/data/pg_hba.conf添加以下内容

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             0.0.0.0/0            scram-sha-256

重启postgresql, 然后在navicat上测试,连接成功 连接测试

关注
打赏
1664501120
查看更多评论
立即登录/注册

微信扫码登录

0.0536s