版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/daijiguo/article/details/82878076
一、下载postgresql的yum源
yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
二、安装postgresql
yum install -y postgresql96-server postgresql96-contrib
三、初始化数据库
/usr/pgsql-9.6/bin/postgresql96-setup initdb
四、添加初始密码
su postgres
psql -U postgres
alter user postgres with password 'new password';
五、让postgresql支持密码登陆
vi /var/lib/pgsql/9.6/data/pg_hba.conf
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 192.168.0.0/16 md5
六、开启远程访问
listen_addresses='*'