一、 安装postgreSql11.2 源
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

yum install -y postgresql11-server postgresql11-contrib

初始化
cd /usr/pgsql-11/bin/
./postgresql-11-setup initdb

设置开机启动
systemctl enable postgresql-11

3.配置远程访问
vim /var/lib/pgsql/11/data/postgresql.conf

如果想对所有IP开放,则将localhost改为*即可,如果想仅对部分IP开放,多个IP之间用,(逗号+空格)隔开。
4.配置账户访问权限
vi /var/lib/pgsql/11/data/pg_hba.conf

5. 启动postgresql 服务
systemctl start postgresql-11.service

5. 设置postgresql用户的登录密码
#su postgres
-bash-3.2$psql -U postgres
postgres=#alter user postgres with password 'new password';
postgres=#exit

6. 重启postgresql 服务
systemctl restart postgresql-11.service
网友评论