在 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 的更多信息。

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

<think>好的,我现在需要帮助用户了解如何将Ubuntu 24.04降级到22.04。首先,我得确认用户的需求。用户可能升级到24.04后遇到了兼容性问题,或者某些软件不支持新版本,所以想回退到更稳定的22.04。 接下来,我要回忆一下Ubuntu的升级机制。通常来说,Ubuntu并不直接支持系统降级,因为升级过程会替换许多系统文件和配置,直接降级可能导致系统不稳定甚至无法启动。所以,用户可能需要通过重新安装系统来实现降级,或者使用备份恢复。 然后,我需要参考用户提供的引用内容。引用[2]是关于从22.04升级到23.04的步骤,但用户现在需要的是反向操作。不过,这里面提到升级是通过`do-release-upgrade`命令进行的,但降级并没有类似的官方工具。因此,可能需要建议用户备份数据并重新安装旧版本。 同时,引用[3]提到在Ubuntu24.04安装Kubernetes集群,这可能暗示用户在使用服务器环境,降级可能涉及更多配置问题,需要特别注意数据备份和配置保存。 接下来,我需要整理降级的可行方法。通常有两种主要途径:使用备份恢复或者全新安装。如果用户有系统备份(比如使用Timeshift),恢复备份是最简单的方法。如果没有备份,可能需要备份数据并重新安装Ubuntu 22.04。 另外,用户可能需要了解降级前的准备工作,比如备份重要文件、记录当前安装的软件包列表、保存配置文件等。这些步骤对于确保数据不丢失至关重要。 还需要提醒用户,降级并非官方支持的操作,存在风险,可能导致数据丢失或系统不稳定,因此建议谨慎操作,并确保有完整备份。 最后,生成相关问题,帮助用户进一步了解相关主题,比如备份工具的使用、系统安装步骤等。</think>### 如何将Ubuntu 24.04降级到22.04Ubuntu官方不提供直接降级的方法,但可以通过以下两种方式实现系统回退: --- #### **方法一:通过备份恢复(推荐)** 1. **前提条件** 若升级前已使用备份工具(如`Timeshift`)创建系统快照,可通过恢复备份实现降级。 ```bash sudo timeshift --restore # 选择升级前的备份快照 ``` 恢复完成后重启系统即可[^2]。 2. **若无备份** 需通过**全新安装Ubuntu 22.04**实现降级,操作步骤如下: - **备份数据**:将个人文件(如`/home`目录、配置文件等)复制到外部存储设备。 - **记录软件列表**:保存当前已安装软件包列表,便于后续恢复: ```bash dpkg --get-selections > package_list.txt ``` - **制作Ubuntu 22.04启动盘**:使用工具如`Rufus`或`BalenaEtcher`创建安装介质。 - **重新安装系统**:启动安装介质,选择“覆盖安装”或手动分区(注意格式化系统分区)。 --- #### **方法二:手动降级(高风险,仅限高级用户)** 此方法需逐包降级依赖项,可能导致系统崩溃,**强烈建议优先选择备份恢复或重装**。 1. **修改软件源** 将`/etc/apt/sources.list`中所有`jammy`(22.04代号)替换`noble`(24.04代号): ```bash sudo sed -i 's/noble/jammy/g' /etc/apt/sources.list ``` 2. **强制降级软件包** ```bash sudo apt update sudo apt dist-upgrade --allow-downgrades -y # 可能因依赖冲突失败 ``` 3. **重启系统** ```bash sudo reboot ``` --- #### **注意事项** 1. **数据安全**:降级可能导致配置文件不兼容,建议优先备份关键数据。 2. **软件兼容性**:部分24.04的软件包在22.04中可能不可用或版本过低。 3. **内核降级**:若手动降级,需额外安装22.04的内核: ```bash sudo apt install linux-image-generic-hwe-22.04 ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值