安装
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql14-server
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14
尝试
切换到数据库用户
su - postgres
登录数据库
psql
查看系统表
select * from pg_roles;
修改监听地址
vim /var/lib/pgsql/14/data/postgresql.conf
# 修改内容,改成非注释
listen_addresses = '*'
port = 5432
修改连接认证方式
vim /var/lib/pgsql/14/data/pg_hba.conf
# 修改内容,改成非注释
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 0.0.0.0/0 trust
host replication all ::1/128 trust
METHOD 全部改成 trust,不安全的方式,非自己的机器请不要这样设置
开放防火墙
firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload