在 Ubuntu 24.04/22.04/20.04 上安装 pgAdmin 4

        这篇文章主要是为了指导新用户如何在 Ubuntu Linux 系统上安装 pgAdmin 4。pgAdmin 是一个功能丰富的开源 PostgreSQL 管理和开发平台,可在 Linux、Unix、Mac OS X 和 Windows 上运行。

        使用 pgAdmin,您可以使用直观且功能强大的 Web 界面管理 PostgreSQL 数据库服务器(从版本 9.2 开始)。

         如果您运行的是 Ubuntu 系统或 Linux Mint,本文将适合您。

        在 Ubuntu 上安装 pgAdmin4 的一个要求是 PostgreSQL 服务器。您可以选择使用任何版本的 PostgreSQL 服务器 >=9.6。 

        在 Ubuntu 上完成 PostgreSQL 数据库服务器的安装后,继续在系统上安装并启动 pgAdmin4。 

1.添加 pgAdmin4 存储库

        所有基于 Debian 的 Linux 操作系统的 pgAdmin 软件包均可从 pgAdmin APT 存储库获取。在此步骤中,我们将存储库添加到我们的 Ubuntu 系统。


curl  -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg
使用下一个命令在您的 Ubuntu 系统中添加pgAdmin存储库:

sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list'
您可以使用以下命令检查创建的存储库文件的内容:

$ cat /etc/apt/sources.list.d/pgadmin4.list
deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/bullseye pgadmin4 main

2. 在 Ubuntu 上安装 pgAdmin4

最后,更新包列表。

sudo apt update
要在 Ubuntu 系统上安装 pgAdmin4 包,请运行以下命令并提供正确的版本号:

sudo apt install pgadmin4

按y键继续在 Ubuntu 上安装pgAdmin4。

....
  cpp-doc gcc-9-locales libdigest-hmac-perl libgssapi-perl libcrypt-ssleay-perl lm-sensors libauthen-ntlm-perl libunicode-map8-perl libunicode-string-perl xml-twig-tools postgresql-12
  postgresql-doc-12 mesa-utils nickle cairo-5c xorg-docs-core
The following NEW packages will be installed:
  cpp cpp-9 fontconfig-config fonts-dejavu-core gcc-9-base libapache2-mod-wsgi-py3 libatomic1 libauthen-sasl-perl libdata-dump-perl libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1
  libencode-locale-perl libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl libfile-mimeinfo-perl libfont-afm-perl libfontconfig1 libfontenc1 libgl1 libgl1-mesa-dri libglapi-mesa
  libglvnd0 libglx-mesa0 libglx0 libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl
  libhttp-message-perl libhttp-negotiate-perl libice6 libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libisl22 libllvm12 liblwp-mediatypes-perl
  liblwp-protocol-https-perl libmailtools-perl libmpc3 libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libpciaccess0 libpq5 libsensors-config libsensors5 libsm6
  libtie-ixhash-perl libtimedate-perl libtry-tiny-perl liburi-perl libvulkan1 libwayland-client0 libwww-perl libwww-robotrules-perl libx11-protocol-perl libx11-xcb1 libxaw7 libxcb-dri2-0
  libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxfixes3 libxft2 libxi6 libxinerama1 libxkbfile1
  libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers
  perl-openssl-defaults pgadmin4 pgadmin4-desktop pgadmin4-server pgadmin4-web postgresql-client postgresql-client-12 postgresql-client-common x11-common x11-utils x11-xserver-utils xdg-utils
0 upgraded, 110 newly installed, 0 to remove and 6 not upgraded.
Need to get 222 MB of archives.
After this operation, 508 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

安装后应该已经启动 Apache 服务。

systemctl status apache2

3. 为 pgAdmin4 配置 Apache Web 服务器

启动 Apache Web 服务器配置。

sudo /usr/pgadmin4/bin/setup-web.sh
这将要求您输入 pgadmin4 用户电子邮件地址并设置密码:


Setting up pgAdmin 4 in web mode on a Debian based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: <input-email-address>
Password: <input-password>
Retype password: <Reenter-password>
pgAdmin 4 - Application Initialisation
======================================

Creating storage and log directories...

同意 Apache Web 服务器的配置。

We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? y
The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y
Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4

4. 访问 pgAdmin 4 Web 界面

如果您配置了 UFW 防火墙,请允许 http 和 https 流量。

sudo ufw allow http && sudo ufw allow https

打开浏览器并。http://[ServerIP_or_domain]/pgadmin4

使用设置的电子邮件地址和密码登录。

等待几秒钟以完成初始化。

        在 pgAdmin 的第一页,点击 “添加新服务器”,添加一个 PostgreSQL 服务器,以便使用 pgAdmin 进行管理。 这可以是本地或远程 PostgreSQL 服务器。

在“常规” 部分下 ,为服务器提供名称和描述。

在“连接” 选项卡下 ,提供访问详细信息 - DB 主机、DB 用户和密码。

完成后,点击 保存 按钮保存配置。如果成功添加服务器,名称将显示在左侧边栏中。

选择服务器以查看数据库摘要信息并进行更改。从文档页面了解有关如何使用 pgAdmin 的更多信息。

如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。

要将 Ubuntu 24.04 降级到 Ubuntu 22.04,可以通过重新安装系统或使用特定工具进行版本回滚。以下是详细步骤: ### 1. 备份重要数据 在进行系统降级之前,必须备份所有重要数据。降级过程涉及系统文件的更改,可能会导致数据丢失。 ### 2. 创建 Ubuntu 22.04 安装介质 - 下载 Ubuntu 22.04 的 ISO 镜像文件。 - 使用工具如 `Rufus` 或 `Ventoy` 将 ISO 文件写入 USB 闪存盘,创建可启动的安装介质。 ### 3. 进入 BIOS 设置 - 重启计算机,在开机时按下相应的键(通常是 `F2`、`F12` 或 `Del`)进入 BIOS 设置。 - 在启动选项中选择 USB 闪存盘作为启动设备。 ### 4. 安装 Ubuntu 22.04 - 启动后,选择“Install Ubuntu”进入安装界面。 - 选择语言、键盘布局等基本设置。 - 在“Installation type”界面,选择“Erase disk and install Ubuntu”或“Something else”进行自定义分区。 - 如果选择“Erase disk and install Ubuntu”,系统会自动格式化硬盘并安装 Ubuntu 22.04。 - 如果选择“Something else”,可以手动调整分区,保留某些数据分区。 ### 5. 完成安装 - 按照提示完成剩余的安装步骤,包括设置用户名、密码等。 - 安装完成后,重启计算机并移除 USB 闪存盘。 ### 6. 验证系统版本 - 系统重启后,打开终端并输入以下命令验证系统版本: ```bash lsb_release -a ``` 确认输出显示 Ubuntu 22.04。 ### 7. 安装必要的开发工具 如果需要安装特定版本的开发工具,例如 `gcc`,可以使用以下命令安装和切换版本: ```bash sudo apt update sudo apt install gcc-10 g++-10 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 ``` 验证安装的版本: ```bash gcc --version g++ --version ``` ### 注意事项 - **数据备份**:确保在降级前备份所有重要数据,避免数据丢失。 - **兼容性**:确保所有硬件和软件在 Ubuntu 22.04 上兼容。 - **系统稳定性**:降级可能会导致某些软件或驱动不兼容,需进行测试。 通过以上步骤,可以顺利将 Ubuntu 24.04 降级到 Ubuntu 22.04。如果在过程中遇到任何问题,建议查阅官方文档或社区支持[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hefeng_aspnet

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值