合 PostgreSQL 16数据库的各种安装方式汇总(yum、编译、docker等)
Tags: PGPostgreSQL安装docker环境yum安装源码编译PG 16
简介
PostgreSQL 16已于2023年9月14日发布,这是世界上最先进的开源数据库的最新版本。相关介绍可以参考:国际新闻:PostgreSQL 16 发布!
本文通过讲解PG 16的各种安装方法。
docker快速使用
详细使用请参考:https://www.dbaup.com/dbbao69zaidockerzhongkuaisushiyonggegebanbendepostgresqlshujuku.html
Docker Hub的官网地址:https://hub.docker.com/_/postgres
GitHub的地址:https://github.com/docker-library/postgres
1 2 3 4 5 6 7 8 9 10 11 12 13 | nohup docker pull postgres:16.0 & docker rm -f lhrpg16 docker run --name lhrpg16 -h lhrpg16 -d -p 54329:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:16.0 docker exec -it lhrpg16 bash docker exec -it lhrpg16 psql -U postgres -d postgres select * from pg_tables; select version(); |
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | [root@lhrdb soft]# docker exec -it lhrpg16 psql -U postgres -d postgres psql (16.0 (Debian 16.0-1.pgdg120+1)) Type "help" for help. postgres=# select version(); version --------------------------------------------------------------------------------------------------------------------- PostgreSQL 16.0 (Debian 16.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit (1 row) postgres=# \l List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges -----------+----------+----------+-----------------+------------+------------+------------+-----------+----------------------- postgres | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | template0 | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres (3 rows) postgres=# create database lhrdb; CREATE DATABASE postgres=# \l List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges -----------+----------+----------+-----------------+------------+------------+------------+-----------+----------------------- lhrdb | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | postgres | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | template0 | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres (4 rows) postgres=# |