如何在 Rocky Linux 9 上安装 PostgreSQL

PostgreSQL 是一个非常流行的开源关系数据库管理系统 (RDBMS)。通常,它用作许多 Web、移动、地理空间和分析应用程序的主要数据存储。PostgreSQL 可以在单个产品中存储结构化和非结构化数据。此外,PostgreSQL 是开源软件,这意味着它可以自由使用、修改和分发。postgresql-logo

在 Rocky Linux 9 上安装 PostgreSQL

步骤 1. 第一步是将您的系统更新到最新版本的软件包列表。为此,请运行以下命令:

sudo dnf check-update
sudo dnf install dnf-utils

步骤 2. 在 Rocky Linux 9 上安装 PostgreSQL。

默认情况下,PostgreSQL 在 Rocky Linux 9 基础存储库中不可用。现在运行以下命令将 PostgreSQL 稳定存储库添加到您的系统:

sudo dnf install http://apt.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

接下来,运行以下命令将 PostgreSQL 的最新稳定版本安装到您​​的服务器:

sudo dnf check-update
sudo dnf install postgresql14-server postgresql14-docs

此外,您可以安装其他模块、二进制文件和库 PostgreSQL:

sudo dnf install postgresql14-libs postgresql14-plperl postgresql14-plpython3 postgresql14-pltcl postgresql14-tcl postgresql14-contrib postgresql14-llvmjit

安装完成后,启动 PostgreSQL 服务并使其在重新启动时自动启动,只需:

sudo systemctl enable postgresql-14 --now
sudo systemctl status postgresql-14

步骤 3. 访问 PostgreSQL 命令提示符。

安装 PostgreSQL 数据库服务器后,默认情况下,它会创建一个postgres角色为 ‘ ‘ 的用户 ‘ postgres‘。它还会创建一个具有相同名称“ postgres”的系统帐户。因此,要连接到 Postgres 服务器,请以 Postgres 用户身份登录系统并连接数据库:

sudo -i -u postgres

您可以使用该psql实用程序访问 PostgreSQL 提示:

psql

现在您已登录到 PostgreSQL 数据库服务器。要检查登录信息,请从数据库命令提示符使用以下命令:

postgres-# \conninfo

要断开与 PostgreSQL 数据库命令提示符的连接,只需键入以下命令并按 Enter。它会让你回到 Rocky Linux 命令提示符:

postgres-# \q

感谢您使用本教程在 Rocky Linux 9 系统上安装 PostgreSQL 14。如需更多帮助或有用信息,我们建议您查看PostgreSQL 官方网站

未经允许不得转载:统信UOS之家 » 如何在 Rocky Linux 9 上安装 PostgreSQL

相关文章