Centos7安装postgresql10并开通外网访问权限
一、获取最新yum源
输入yuminstallhttps://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm-y
二、使用yum安装postgresql10
输入yuminstallpostgresql10-contribpostgresql10-server-y
出现以下文字则说明安装成功
三、初始化数据库
初始化数据库/usr/pgsql-10/bin/postgresql-10-setupinitdb
启动数据库systemctlstartpostgresql-10
添加到开机启动systemctlenablepostgresql-10.service

四、配置数据库
切换用户su-postgres
连接数据库psql
设置数据库密码ALTERUSERpostgresWITHPASSWORD‘password’;
退出\q
五、postgresql配置外网访问
编辑pg_hba.conf文件vi/var/lib/pgsql/10/data/pg_hba.conf
翻到文件最后,将最后三行注释,并添加一行代码
hostallall0.0.0.0/0md5
编辑postgresql.conf文件vi/var/lib/pgsql/10/data/postgresql.conf
将listen_addresses修改为listen_addresses=‘*’

重启postgresql
systemctlrestartpostgresql-10
六、测试postgresql连接

原文链接:https://blog.csdn.net/qq_35169985/article/details/89218508