您的当前位置:首页正文

Deepin下安装PostgreSQL

2024-10-17 来源:个人技术集锦

Deepin下安装Postgresql

我的Deepin版本为

$ lsb_release -aNo LSB modules are available.Distributor ID: DeepinDescription:    Deepin 20.9Release:        20.9Codename:       apricot

注意这里Codename是apricot,后面会提到。

由于Deepin的apt连接的是Deepin官方源,其中的软件版本十分老旧,直接使用

$ sudo apt install postgresql

下载的版本是 11,而这已经是PostgreSQL的不支持版本。

好在 告诉我们他们提供了官方Apt仓库,可以通过以下方式设置:

$ sudo apt install -y postgresql-common$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

报错

$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.shThis script will enable the PostgreSQL APT repository on apt.postgresql.org onyour system. The distribution codename used will be apricot-pgdg.Your system is using the distribution codename apricot, but apricot-pgdgdoes not seem to be a valid distribution onhttp://apt.postgresql.org/pub/repos/apt/dists/We abort the installation here. If you want to use a distribution differentfrom your system, you can call this script with an explicit codename, e.g."/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh precise".Specifically, if you are using a non-LTS Ubuntu release, refer tohttps://wiki.postgresql.org/wiki/Apt/FAQ#I_am_using_a_non-LTS_release_of_UbuntuFor more information, refer to https://wiki.postgresql.org/wiki/Aptor ask on the mailing list for assistance: pgsql-pkg-debian@postgresql.org

看内容可以看出来,apricot不是合法的codename,因为我们毕竟不是在原生Debian上安装。

前往报错中提示的 查看

这实际上是

而在 ,也列出了支持的Debian版本

查询本系统基于的Debian版本:

$ cat /etc/debian_version10.10

应该使用buster作为Codename,结合报错信息中给的例子,重新执行

$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh busterThis script will enable the PostgreSQL APT repository on apt.postgresql.org onyour system. The distribution codename used will be buster-pgdg.Press Enter to continue, or Ctrl-C to abort.Writing /etc/apt/sources.list.d/pgdg.list ...Importing repository signing key ...OKRunning apt-get update ...命中:1 https://pro-driver-packages.uniontech.com eagle InRelease命中:2 https://dl.google.com/linux/chrome/deb stable InRelease                                               命中:4 https://community-packages.deepin.com/deepin apricot InRelease                                        命中:5 https://community-packages.deepin.com/driver driver InRelease                                         命中:3 https://packages.microsoft.com/repos/code stable InRelease                                            命中:6 https://community-packages.deepin.com/printer eagle InRelease                                         获取:7 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease [157 kB]                                获取:8 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 Packages [349 kB]                      获取:9 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main i386 Packages [344 kB]        命中:10 https://app-store-files.uniontech.com/240709181548520/appstore deepin InRelease已下载 850 kB,耗时 5秒 (188 kB/s)正在读取软件包列表... 完成You can now start installing packages from apt.postgresql.org.Have a look at https://wiki.postgresql.org/wiki/Apt for more information;most notably the FAQ at https://wiki.postgresql.org/wiki/Apt/FAQ

执行成功,查看postgresql最新版本

$ apt show postgresqlPackage: postgresqlVersion: 16+261.pgdg100+1Priority: optionalSection: databaseSource: postgresql-common (261.pgdg100+1)Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>Installed-Size: 74.8 kBDepends: postgresql-16Suggests: postgresql-docDownload-Size: 69.5 kBAPT-Sources: http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 PackagesDescription: object-relational SQL database (supported version) This metapackage always depends on the currently supported PostgreSQL database server version. . PostgreSQL is a fully featured object-relational database management system.  It supports a large part of the SQL standard and is designed to be extensible by users in many aspects.  Some of the features are: ACID transactions, foreign keys, views, sequences, subqueries, triggers, user-defined types and functions, outer joins, multiversion concurrency control.  Graphical user interfaces and bindings for many programming languages are available as well.N: 有 1 条附加记录。请加上 ‘-a’ 参数来查看它们

更新软件包

$ sudo apt upgrade

查看当前版本

$ sudo apt list postgresql正在列表... 完成postgresql/buster-pgdg,buster-pgdg,now 16+261.pgdg100+1 all [已安装]N: 还有 1 个版本。请使用 -a 选项来查看它(他们)。

在PostgreSQL中查看版本

$ psql --versionpsql (PostgreSQL) 16.3 (Debian 16.3-1.pgdg100+1)

更新成功

显示全文