数据库postgresql14
在官网上跟着命令下载 Postgresql14
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
完成后用自带的用户postgres创建数据库和用户密码
su - postgres
psql
create database test_db;
create user test_user with password '123456';
配置远程数据库连接,编辑/var/lib/pgsql/14/data下的两个文件


添加防火墙释放端口,更新防火墙
firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload
在本地连接服务器数据库,导入本地数据库数据到服务器。

pg_dump -h localhost -p 5432 -U 用户名 -d 数据库名>导出位置.database.bak
psql -d test_db -h 服务器主机地址 -p 5432 -U test_user -f 导出位置database.bak