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上测试,连接成功