在 Ubuntu服务器 18.04 LTS 上安装 pgAdmin 4
PGDG 存储库还提供 pgAdmin 和相关包。
因此,我们可以使用 apt 命令轻松安装它。
但首先,我们必须更新 Ubuntu 服务器上的软件包。
jackli@ubuntu-server:~$ sudo apt update Get:1 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease [46.3 kB] Hit:2 http://pk.archive.ubuntu.com/ubuntu bionic InRelease Get:3 http://pk.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:4 http://pk.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Get:5 http://pk.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 Packages [179 kB] Get:7 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [871 kB] Get:8 http://pk.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,054 kB] Fetched 2,403 kB in 31s (78.2 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 7 packages can be upgraded. Run 'apt list --upgradable' to see them.
升级可用的软件包。
jackli@ubuntu-server:~$ sudo apt upgrade -y Reading package lists... Done Building dependency tree
使用 apt 命令安装 pgAdmin 4 和相关软件包。
jackli@ubuntu-server:~$ sudo apt install -y pgadmin4 pgadmin4-apache2
pgAdmin 4 安装过程将启动基于 TUI(终端用户界面)的配置屏幕。
输入电子邮件地址以创建 pgAdmin Web 界面的用户帐户。
按确定按钮。
为 pgAdmin Web 界面用户设置密码,然后按确定按钮。
pgAdmin 安装将继续如下。
Setting up libwacom-common (0.29-1) ... Setting up libxdamage1:amd64 (1:1.1.4-3) ... Enabling site 000-default. info: Executing deferred 'a2enconf javascript-common' for package javascript-common Enabling conf javascript-common. info: Executing deferred 'a2enmod wsgi' for package libapache2-mod-wsgi-py3 Enabling module wsgi. Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service -> /lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service -> /lib/systemd/system/apache-htcacheclean.service. Setting up gsettings-desktop-schemas (3.28.0-1ubuntu1) ... 。。。 Setting up libgtk-3-bin (3.22.30-1ubuntu4) ... Setting up qt5-gtk-platformtheme:amd64 (5.9.5+dfsg-0ubuntu2.5) ... Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-2) ... Processing triggers for libc-bin (2.27-3ubuntu1) ...
pgAdmin 4 已安装在 Ubuntu服务器 18.04 LTS 上。
pgAdmin Web 应用程序运行在默认的 http 服务端口。
因此,要访问 pgAdmin 4,我们需要在 Ubuntu 防火墙中允许 http 服务端口。
jackli@ubuntu-server:~$ sudo ufw allow http Rules updated Rules updated (v6)
要访问 pgAdmin 4 Web 界面,请在浏览器中打开 URL http://postgresql-01.onitroad.com/pgadmin4.
使用我们在 pgAdmin 4 安装期间创建的电子邮件/密码登录。
PostgreSQL(或者 Postgres)是一个 RDBMS(关系数据库管理系统),它强调可扩展性和技术标准合规性。
pgAdmin 4 是基于 Web 的界面,用于 PostgreSQL 服务器的数据库管理。
pgAdmin 是 PostgreSQL 最流行且功能丰富的 Web 界面。
在本文中,我们将学习如何在 Ubuntu服务器 18.04 LTS 上安装 PostgreSQL 和 pgAdmin 4.
在 pgAdmin 4 中添加 PostgreSQL 服务器
在 pgAdmin 4 仪表板中,单击添加新服务器以在我们的 pgAdmin 4 Web 界面中添加 PostgreSQL 数据库服务器。
单击“保存”以添加本地 postgreSQL 服务器。
我们已经在 Ubuntu服务器 18.04 LTS 上成功安装了 PostgreSQL 和 pgAdmin 4.
在 Ubuntu服务器 18.04 LTS 上安装 PostgreSQL
我们正在使用 apt 命令安装 PostgreSQL 和相关软件包。
jackli@ubuntu-server:~$ sudo apt -y install postgresql postgresql-contrib [sudo] password for jackli: Reading package lists... Done
PostgreSQL 安装过程会创建一个默认的操作系统用户 postgres 来拥有 PostgreSQL 文件和进程。
切换到 postgres 用户。
jackli@ubuntu-server:~$ sudo su - postgres
使用 psql 命令连接到 PostgreSQL 并为 postgres(数据库用户)设置密码。
postgres@ubuntu-server:~$ psql psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1)) Type "help" for help. postgres=# ALTER USER postgres PASSWORD '123'; ALTER ROLE postgres=# \q postgres@ubuntu-server:~$ exit logout
在 Ubuntu 服务器上安装 PostgreSQL APT 存储库
下载并导入 PostgreSQL apt 存储库的 GPG Key。
jackli@ubuntu-server:~$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add OK
通过创建存储库源文件添加 PostgreSQL apt 存储库。
jackli@ubuntu-server:~$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'