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>