- Install the repository RPM:
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
- Install the client packages:
yum install postgresql12
- Optionally install the server packages:
yum install postgresql12-server
- Optionally initialize the database and enable automatic start:
/usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12 systemctl start postgresql-12
5.修改密码
su - postgres
psql
效果:
输入修改密码的命令:
ALTER USER postgres WITH PASSWORD '123456';
退出
退出:\q
备注其他:列出所有库\l 列出所有用户\du 列出库下所有表\d
6、默认情况下postgresql是不用密码不支持远程登录的。我们需要修改配置文件
修改配置
vi /var/lib/pgsql/12/data/pg_hba.conf
修改后:
保存退出
我们改远程访问
vi /var/lib/pgsql/12/data/postgresql.conf
修改后的
保存退出重启
systemctl restart postgresql-12
关闭防火墙
systemctl stop firewalld.service
查看防火墙状态
systemctl status firewalld.service