1、yum方式安装
创建文件 :psql_install.sh
#!/bin/bash
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql13-server
/usr/pgsql-13/bin/postgresql-13-setup initdb
systemctl enable postgresql-13
systemctl start postgresql-13
运行安装脚本
bash psql_install.sh
2、进入postgresql
su - postgres
进入sql命令行
psql
3、创建超级用户
create user admin with password '123456' SUPERUSER;
4、创建数据库
create database testdb;
5、配置远程连接
修改本地配置文件:
/var/lib/pgsql/13/data/pg_hba.conf
...
host all all 0.0.0.0/0 password
/var/lib/pgsql/13/data/postgresql.conf
...
listen_addresses = '*'
重启postgresql
systemctl restart postgresql-13