# 1.创建源#deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
zhangyanfeng@ubuntu:/etc/apt$ cd sources.list.d/
zhangyanfeng@ubuntu:/etc/apt/sources.list.d$ ls
sogoupinyin.list
zhangyanfeng@ubuntu:/etc/apt/sources.list.d$ sudo touch pgdg.list
zhangyanfeng@ubuntu:/etc/apt/sources.list.d$ ls
pgdg.list sogoupinyin.list
zhangyanfeng@ubuntu:/etc/apt/sources.list.d$ vim pgdg.list
zhangyanfeng@ubuntu:/etc/apt/sources.list.d$ cat pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
#3.安装#sudo apt-get install postgresql
zhangyanfeng@ubuntu:/etc/apt/sources.list.d$ sudo apt-get install postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.15.0-101 linux-headers-4.15.0-101-generic linux-image-4.15.0-101-generic linux-modules-4.15.0-101-generic linux-modules-extra-4.15.0-101-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libpq-dev libpq5 pgdg-keyring postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common sysstat
Suggested packages:
postgresql-doc-12 postgresql-doc libjson-perl isag
The following NEW packages will be installed:
pgdg-keyring postgresql postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common sysstat
The following packages will be upgraded:
libpq-dev libpq5
2 upgraded, 7 newly installed, 0 to remove and 389 not upgraded.
Need to get 17.0 MB of archives.
After this operation, 54.5 MB of additional disk space will be used.Do you want to continue? [Y/n] Y
Get:1 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 libpq-dev amd64 12.3-1.pgdg18.04+1 [138 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 sysstat amd64 11.6.1-1ubuntu0.1 [295 kB]
Get:3 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 libpq5 amd64 12.3-1.pgdg18.04+1 [173 kB]
Get:4 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 pgdg-keyring all 2018.2 [10.7 kB]
Get:5 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 postgresql-client-common all 215.pgdg18.04+1 [87.4 kB]
Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 postgresql-client-12 amd64 12.3-1.pgdg18.04+1 [1,413 kB]
Get:7 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 postgresql-common all 215.pgdg18.04+1 [237 kB]
Get:8 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 postgresql-12 amd64 12.3-1.pgdg18.04+1 [14.6 MB]