扫码一下
查看教程更方便
要开始了解 postgresql 基础知识,首先让我们安装 postgresql。本章解释了如何在 linux平台上安装 postgresql。
按照给定的步骤在你的 linux 机器上安装 postgresql。在继续安装之前,请确保使用的是root身份登录的系统。
打开 postgresql ag捕鱼王app官网 download ,可以看到这里包含了很多平台的安装包,包括 linux、windows、mac os等 。
linux 我们可以看到支持 ubuntu 和 red hat 等各个平台,点击具体的平台链接,即可查看安装方法:
点击上图中的 file browser,我们可以下载 postgresql 最新的源码。
本章节以 centos 为例。
这里我们用的是截止目前最新的版本
# install the repository rpm:
[root@localhost ~]$ yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/el-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# install postgresql:
[root@localhost ~]$ yum install -y postgresql13-server
安装成功之后,下面我们开始初始化数据库
[root@localhost ~]$ /usr/pgsql-13/bin/postgresql-13-setup initdb
结果如下图所示
可以使用以下命令 启用并开启 postgresql服务
[root@localhost ~]$ systemctl enable postgresql-13
[root@localhost ~]$ systemctl start postgresql-13