官网教程
-
选择
Download
-
Linux
->Red Hat/CentOS
安装步骤
# Install the repository RPM:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Disable the built-in PostgreSQL module:
sudo dnf -qy module disable postgresql
# Install PostgreSQL:
sudo dnf install -y postgresql12-server
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl enable postgresql-12
sudo systemctl start postgresql-12
开启远程访问
-
查找
postgresql.conf
文件-
find -name postgresql.conf
-
-
vim编辑文件
-
vim ./var/lib/pgsql/12/data/postgresql.conf
-
-
修改
listen_addresses
为*
-
查找
pg_hba.conf
文件-
find -name pg_hba.conf
-
-
vim编辑文件
-
vim ./var/lib/pgsql/12/data/pg_hba.conf
-
-
# IPv4 local connections:
后追加内容外网访问配置-
host all all 0.0.0.0/0 md5 #允许外网访问,,密码md5加密
-
-
防火墙开放
5432
端口-
开放端口
-
firewall-cmd --zone=public --add-port=5432/tcp --permanent
-
-
配置立即生效
-
firewall-cmd --reload
-
-
查看端口是否开启成功
-
firewall-cmd --query-port=5432/tcp
-
-
-
Navicat
连接测试