Ubuntu 上如何安装 PostgreSQL?

直接使用 apt 来安装:

sudo apt update
sudo apt install postgresql postgresql-contrib

安装完成后,使用默认用户 postgres 连接默认数据库 postgres。

  1. 切换 Linux 用户为 postgres

    sudo -iu postgres

  2. 登录 psql

    psql

这样就打开了 postgres 数据库。

从上面的操作可以看出,安装 Postgres,自动就创建了:

  1. postgres 的Linux系统用户
  2. postgres 的数据库用户
  3. postgres 数据库

而且你使用数据库用户的登录psql时,会自动打开与用户同名的数据库。

发布了197 篇原创文章 · 获赞 88 · 访问量 58万+

猜你喜欢

转载自blog.csdn.net/henryhu712/article/details/104104412