yum安装
代码语言:javascript复制yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql11-server
/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
允许远程登陆
代码语言:javascript复制vi /var/lib/pgsql/11/data/postgresql.conf
修改listen_addresses = '*'
修改pg.hba文件需要重启服务
代码语言:javascript复制vi /var/lib/pgsql/11/data/pg_hba.conf
在最后一行添加
host all all 0.0.0.0/0 md5
切换到postgres用户。然后执行修改用户密码SQL语句。其中“postgres”为要修改密码的用户,“123456”为用户的密码
代码语言:javascript复制su - postgres
psql -c "alter user postgres with password '123456'"