当前位置:网站首页>Quickly use various versions of PostgreSQL database in docker
Quickly use various versions of PostgreSQL database in docker
2022-07-06 23:53:00 【Hua Weiyun】
1、 Installation Overview
PG There are many ways to install , and MySQL similar , Give users a lot of choice . Such as :RPM Package installation ( On-line 、 offline )、 Source code compilation and installation 、 Binary etc .
https://yum.postgresql.org/rpmchart.php
https://yum.postgresql.org/11/redhat/rhel-6-x86_64/repoview/postgresqldbserver11.group.html
https://www.postgresql.org/ftp/source/
open PostgreSQL Official website https://www.postgresql.org/, Click... On the menu bar Download , As you can see, there are many installation packages for the platform , Include Linux、Windows、Mac OS etc. .
Each installation package :https://www.postgresql.org/ftp/source/
Linux We can see support Ubuntu and Red Hat And so on , Click on the specific platform link , You can see the installation method :
Click on the image above file browser, We can also download PostgreSQL The latest source code .
2、Docker Download create in
Docker Hub Official website :https://hub.docker.com/_/postgres
GitHub The address of :https://github.com/docker-library/postgres
-- Pull all images docker pull postgres:9.4.26 docker pull postgres:9.6.24docker pull postgres:10.20docker pull postgres:11.15docker pull postgres:12.10docker pull postgres:13.6docker pull postgres:14.2-- Create versions of Docker Containers docker rm -f lhrpg94 lhrpg96 lhrpg10 lhrpg11 lhrpg12 lhrpg13 lhrpg14docker run --name lhrpg94 -h lhrpg94 -d -p 54321:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:9.4.26docker run --name lhrpg96 -h lhrpg96 -d -p 54322:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:9.6.24docker run --name lhrpg10 -h lhrpg10 -d -p 54323:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:10.20docker run --name lhrpg11 -h lhrpg11 -d -p 54324:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:11.15docker run --name lhrpg12 -h lhrpg12 -d -p 54325:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:12.10docker run --name lhrpg13 -h lhrpg13 -d -p 54326:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:13.6docker run --name lhrpg14 -h lhrpg14 -d -p 54327:5432 -e POSTGRES_PASSWORD=lhr -e TZ=Asia/Shanghai postgres:14.2
3、 Login test
-- docker Direct landing docker exec -it lhrpg14 psql -U postgres -d postgres-- Local landing docker exec -it lhrpg14 bashsu - postgrespsql-- Remote login psql -U postgres -h 192.168.66.35 -d postgres -p54327-- from Postgresql 9.2 Start , You can also use URI Format for remote connection :psql postgresql://myuser:[email protected]:5432/mydbpsql postgresql://postgres:[email protected]:54327/postgres
among -h Parameter specifies the server address , The default is 127.0.0.1, It is not specified by default ,-d Specify the database selected after connection , The default is postgres,-U Designated user , The default is the current user ,-p Specify port number , The default is "5432", More parameter options are available : ./bin/psql --help see .
C:\Users\lhrxxt>psql -U postgres -h 192.168.66.35 -d postgres -p54327Password for user postgres:psql (13.3)Type "help" for help.postgres=# select version(); version------------------------------------------------------------------------------------------------------------------ PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit(1 row)postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges-----------+----------+----------+-------------------+-------------------+----------------------- postgres | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | template0 | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | =c/postgres + | | | | | postgres=CTc/postgres(3 rows)postgres=# CREATE DATABASE lhrdb WITH OWNER=postgres ENCODING='UTF-8';CREATE DATABASEpostgres=# \c lhrdbYou are now connected to database "lhrdb" as user "postgres".lhrdb=#lhrdb=# create table student (lhrdb(# id integer not null,lhrdb(# name character(32),lhrdb(# number char(5),lhrdb(# constraint student_pkey primary key (id)lhrdb(# );CREATE TABLElhrdb=#lhrdb=# \d student Table "public.student" Column | Type | Collation | Nullable | Default--------+---------------+-----------+----------+--------- id | integer | | not null | name | character(32) | | | number | character(5) | | |Indexes: "student_pkey" PRIMARY KEY, btree (id)lhrdb=#lhrdb=# INSERT INTO student (id, name, number) VALUES (1, ' Zhang San ', '1023');INSERT 0 1lhrdb=# SELECT * FROM student WHERE id=1; id | name | number----+------------------------------------+-------- 1 | Zhang San | 1023(1 row)
Is it convenient .
Installation configuration completed , If you don't understand , You can chat with Mr. Mai privately .
边栏推荐
- DAY FIVE
- [boutique] Pinia Persistence Based on the plug-in Pinia plugin persist
- 11 preparations for Web3 and Decentralization for traditional enterprises
- 【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
- 1000 words selected - interface test basis
- Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
- Master binary tree in one article
- The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
- How to find out if the U disk file of the computer reinstallation system is hidden
- ArrayExpress数据库里的细胞只有两个txt是不是只能根据Line到ENA下载测序跑矩阵?
猜你喜欢
Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
Close unregistering application XXX with Eureka with status down after Eureka client starts
Gradle knowledge generalization
自动化测试工具Katalon(Web)测试操作说明
Talking about the current malpractice and future development
基于SSM框架实现的房屋租赁管理系统
Implementation steps of mysql start log in docker
《数字经济全景白皮书》保险数字化篇 重磅发布
【无人机】多无人协同任务分配程序平台含Matlab代码
Wu Enda 2022 machine learning course evaluation is coming!
随机推荐
Unity color palette | color palette | stepless color change function
pytest多进程/多线程执行测试用例
【无人机】多无人协同任务分配程序平台含Matlab代码
If the request URL contains jsessionid, the solution
The largest single investment in the history of Dachen was IPO today
Matplotlib draws a histogram and adds values to the graph
Pinia module division
I've been laid off, and I'll lose money for everything. The days when I once made a monthly salary of 20000 are not coming back
PostgreSQL高可用之repmgr(1主2从+1witness)+Pgpool-II实现主从切换+读写分离
1000 words selected - interface test basis
17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
自动化测试工具Katalon(Web)测试操作说明
Win11怎么恢复传统右键菜单?Win11右键改回传统模式的方法
The programmer said, "I'm 36 years old, and I don't want to be rolled, let alone cut."
Zero code and high return. How to use 40 sets of templates to meet 95% of the reporting needs in the work
Gradle知识概括
PDF文档签名指南
okcc呼叫中心的订单管理时怎么样的
电脑重装系统u盘文件被隐藏要怎么找出来
AI金榜题名时,MLPerf榜单的份量究竟有多重?