PostgresSql14数据库的安装

本文详细介绍了在CentOS8上安装PostgreSQL14的步骤,包括下载资源、禁用内置模块、安装数据库、初始化、启动服务以及创建数据库和用户。还涉及了配置文件`pg_hba.conf`和`postgresql.conf`的修改,确保远程连接的设置,并给出了通过Navicat连接数据库的提示。最后,文章提供了在遇到问题时如何正确重启数据库的方法。
摘要由CSDN通过智能技术生成


欢迎大家加入CSDN开发云
CSDN开发云

1. 准备工作

① 打开PostgrsSql官网https://www.postgresql.org/,点击“Download”按钮;
请添加图片描述
② 选择符合安装环境的系统版本,以Centos8为例
请添加图片描述
③ 安装方式
请添加图片描述
④ 安装命令

#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 postgresql14-server

#Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14

2. 创建数据库

① 使用命令“su postgres”;进入用户;
请添加图片描述
② 使用命令“psql”;
请添加图片描述
③ 使用“\l”命令;查看数据库;
请添加图片描述
④ 使用命令“create user odoo15 with password 'odoo15';”,创建角色‘’ 请添加图片描述
⑤ 使用命令“\du”,查看所有角色;
请添加图片描述
⑥ 使用命令“ALTER ROLE odoo15 WITH superuser;”,给用户赋权限;
请添加图片描述
⑦ 使用命令“CREATE DATABASE odoo15_test OWNER odoo15;”,创建数据库;数据库名称为:odoo15_test;
请添加图片描述
⑧ 使用命令“GRANT ALL PRIVILEGES ON DATABASE odoo15_test TO odoo15;”,给数据库赋权限;
请添加图片描述
⑨ 使用命令“ctrl+z”,退出用户;
⑩ 退出后会出现bash-4.4$提示符,不能使用命令“exit”退出,之后重启数据库会报错无法连接”Failed to start PostgreSQL 14 database“;直接关闭ssh,重新连接虚拟机或服务器,再对数据库进行重启;

3 在根目录下使用命令“find . -name 'pg_*'”,查询配置文件所在位置;

请添加图片描述

4 使用命令“cd /var/lib/pgsql/14/data/”,进入配置文件目录;

请添加图片描述

5 修改配置文件pg_hba.conf;

请添加图片描述

6 重启数据库,使用命令“service postgresql-14 restart”也可以;

重启数据库

7 设置通过Navicat连接数据库,与第六步无关,有冲突;

① 在var/lib/pgsql/14/data/文件夹中找到“postgresql.conf”文件,使用命令“vim postgresql.conf”,修改两处配置;“listen_addresses = ‘*’”,“port = 5432”;
请添加图片描述
② 在var/lib/pgsql/14/data/文件夹中找到“pg_hba.conf”文件,使用命令“vim pg_hba.conf”,修改配置文件;
请添加图片描述
③ 修改上述配置文件后重启数据库;

欢迎大家加入CSDN开发云
CSDN开发云

This release contains a variety of fixes from 14.0. For information about new features in major release 14, see Section E.2. A dump/restore is not required for those running 14.X. However, note that installations using physical replication should update standby servers before the primary server, as explained in the third changelog entry below. Also, several bugs have been found that may have resulted in corrupted indexes, as explained in the next several changelog entries. If any of those cases apply to you, it's recommended to reindex possibly-affected indexes after updating. Make the server reject extraneous data after an SSL or GSS encryption handshake (Tom Lane) A man-in-the-middle with the ability to inject data into the TCP connection could stuff some cleartext data into the start of a supposedly encryption-protected database session. This could be abused to send faked SQL commands to the server, although that would only work if the server did not demand any authentication data. (However, a server relying on SSL certificate authentication might well not do so.) The PostgreSQL Project thanks Jacob Champion for reporting this problem. (CVE-2021-23214) Make libpq reject extraneous data after an SSL or GSS encryption handshake (Tom Lane) A man-in-the-middle with the ability to inject data into the TCP connection could stuff some cleartext data into the start of a supposedly encryption-protected database session. This could probably be abused to inject faked responses to the client's first few queries, although other details of libpq's behavior make that harder than it sounds. A different line of attack is to exfiltrate the client's password, or other sensitive data that might be sent early in the session. That has been shown to be possible with a server vulnerable to CVE-2021-23214. The PostgreSQL Project thanks Jacob Champion for reporting this problem. (CVE-2021-23222) Fix physical replication for cases where the primary crashes after shipping a WAL se
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值