**
CentOS 7安装 PostgreSQL 14 教程
环境说明
系统:CentOS 7_x86_64_2009
http://mirrors.163.com/centos/7.9.2009/isos/x86_64/
数据库:直接从使用yum工具进行安装
安装步骤
1、添加yum源
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2、执行yum的安装
sudo yum install -y postgresql14-server
3、初始化postgreSQL
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
4、设置开机启动和启动server服务
systemctl enable postgresql-14
systemctl start postgresql-14
5、切换用户,执行psql命令连接postgreSQL服务端
su - postgres
psql
6、在psql命令模式是创建角色、库、并授权(只需要把中文替换称自己的定义的内容就行)
create user 用户名 with password '密码'; //创建角色
create database 数据库名称 owner 用户名; // 创建数据库
grant all privileges on database 数据库名称 to 用户名;
设置开启远程访问
1、所有IP开放访问
vi /var/lib/pgsql/14/data/postgresql.conf
找到listen_address
listen_address = '*' // 将localhost改成*
port = 5432 //可以修改自定义端口
2、增加信任连接
vi /var/lib/pgsql/14/data/pg_hba.conf
增加配置
# IPv4 local connections:
host all all 0.0.0.0/0 trust
3、重启PostgreSQL服务
PostgreSQL安装扩展(uuid-ossp等)
*这个还没找到靠谱解决方案 *
**