docker 安装mysql5.6.51

docker 安装mysql5.6.51

版本信息

webrx@us:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
webrx@us:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:42 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
webrx@us:~$ 

下载

docker pull mysql:5.6.51

webrx@us:~$ docker pull mysql:5.6.51
5.6.51: Pulling from library/mysql
35b2232c987e: Downloading 
fc55c00e48f2: Downloading 
0030405130e3: Downloading 
e1fef7f6a8d1: Downloading 
1c76272398bb: Downloading 
f57e698171b6: Downloading 
f5b825b269c0: Downloading 
dcb0af686073: Downloading 
27bbfeb886d1: Downloading 
6f70cc868145: Download complete 
1f6637f4600d: Download complete 
5.6.51: Pulling from library/mysql
35b2232c987e: Pull complete 
fc55c00e48f2: Pull complete 
0030405130e3: Pull complete 
e1fef7f6a8d1: Pull complete 
1c76272398bb: Pull complete 
f57e698171b6: Pull complete 
f5b825b269c0: Pull complete 
dcb0af686073: Pull complete 
27bbfeb886d1: Pull complete 
6f70cc868145: Pull complete 
1f6637f4600d: Pull complete 
Digest: sha256:20575ecebe6216036d25dab5903808211f1e9ba63dc7825ac20cb975e34cfcae
Status: Downloaded newer image for mysql:5.6.51
docker.io/library/mysql:5.6.51
webrx@us:~$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
mysql        latest    17b062d639f4   31 hours ago   519MB
mysql        5.6.51    dd3b2a5dcb48   2 months ago   303MB

建立容器并测试

docker ps

docker ps -a

docker run -itdP -e MYSQL_ROOT_PASSWORD=root -e TZ='Asia/Shanghai' mysql:5.6.51

docker run -it --rm mysql:5.6.51 mysql -h192.168.0.68 -uroot -p -P49156

webrx@us:~$ docker ps 
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
webrx@us:~$ docker ps  -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
webrx@us:~$ docker run -itdP -e MYSQL_ROOT_PASSWORD=root -e TZ='Asia/Shanghai' mysql:5.6.51
832f4493c041942f977268e305d823269e4262ec383ee8a7556825045cdeecc1
webrx@us:~$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                                         NAMES
832f4493c041   mysql:5.6.51   "docker-entrypoint.s…"   4 seconds ago   Up 3 seconds   0.0.0.0:49156->3306/tcp, :::49156->3306/tcp   priceless_austin
webrx@us:~$ docker run -it --rm mysql:5.6.51 mysql -h192.168.0.68 -uroot -p -P49156
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version(),now(),@@basedir,@@datadir,user(),database();
+-----------+---------------------+-----------+-----------------+-----------------+------------+
| version() | now()               | @@basedir | @@datadir       | user()          | database() |
+-----------+---------------------+-----------+-----------------+-----------------+------------+
| 5.6.51    | 2022-02-19 16:09:43 | /usr/     | /var/lib/mysql/ | root@172.17.0.1 | NULL       |
+-----------+---------------------+-----------+-----------------+-----------------+------------+
1 row in set (0.00 sec)

mysql> 

image-20220219161527756

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值