PostgreSQL 是一个开源的对象关系数据库系统。它是用于生产服务器的领先数据库服务器之一。 PostgreSQL 允许我们用各种编程语言执行存储过程,如 PHP、C/C++、Python、Java、Perl、Ruby 以及它自己的 PL/pgSQL,类似于 Oracle 的 PL/SQL。
Postgres 数据库用于数据的持久存储
安装 Postgres
yum install postgres
(注意:记住 postgres 用户的密码——你以后需要它)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.6
设置 Postgres
启动 pgAdmin。
连接到本地服务器。使用 localhost 作为服务器名称,使用 postgres 作为用户名和安装 Postgres 时使用的密码。
执行此命令需要root用户。注意:如果安装时没有设置密码(sudo apt-get install postgresql),则可以如下设置:

sudo -u postgres psql postgres
在 postgres 客户端提示符下,使用以下命令设置密码。
alter user postgres with password 'postgres';
连接到 PostgreSQL
安装 PostgreSQL 数据库服务器后,默认情况下,它会创建一个角色为“postgres”的用户“postgres”。它还创建一个具有相同名称“postgres”的系统帐户。因此,要连接到 postgres 服务器,请以用户 postgres 登录到您的系统并连接数据库。
$ sudo su - postgres
$ psql
现在您已登录到 PostgreSQL 数据库服务器。要检查登录信息,请从数据库命令提示符使用以下命令。
postgres-# \conninfo
要断开与 PostgreSQL 数据库命令提示符的连接,只需键入以下命令并按 Enter。它会让你回到 Ubuntu 命令提示符。
postgres-# \q