介绍
https://hub.docker.com/_/mysql
http://hub.daocloud.io
1docker search mysql
2
3
4nohup docker pull mysql:5.5.62 &
5nohup docker pull mysql:5.6.51 &
6nohup docker pull mysql:5.7.43 &
7nohup docker pull mysql:8.0.34 &
8nohup docker pull mysql:8.1.0 &
9
10
11docker rm mysql55 -f
12docker rm mysql56 -f
13docker rm mysql57 -f
14docker rm mysql80 -f
15docker rm mysql81 -f
16
17
18mkdir -p /etc/mysql/mysql55/
19mkdir -p /etc/mysql/mysql56/
20mkdir -p /etc/mysql/mysql57/
21mkdir -p /etc/mysql/mysql80/
22mkdir -p /etc/mysql/mysql81/
23
24
25cat > /etc/mysql/mysql55/conf/my.cnf -v /etc/mysql/mysql8030/conf:/etc/mysql/conf.d \
3> -e MYSQL_ROOT_PASSWORD=lhr -e TZ=Asia/Shanghai \
4> mysql:8.0.30
5f6e94a91fd69e26d0e9e7bd5b4ef11ecde0f4b8502299c537342141ea01bf80a
6root@lhrxxt:~#
7root@lhrxxt:~# cat > /etc/mysql/mysql8030/conf/my.cnf default-time-zone = '+8:00'
10> log_timestamps = SYSTEM
11> skip-name-resolve
12> log-bin
13> server_id=80303418
14> character_set_server=utf8mb4
15> EOF
16root@lhrxxt:~# docker restart mysql8030
17mysql8030
18root@lhrxxt:~# docker exec -it mysql8030 bash
19bash-4.4# mysql
20ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
21bash-4.4# mysql -uroot -plhr
22mysql: [Warning] Using a password on the command line interface can be insecure.
23Welcome to the MySQL monitor. Commands end with ; or \g.
24Your MySQL connection id is 9
25Server version: 8.0.30 MySQL Community Server - GPL
26
27Copyright (c) 2000, 2022, Oracle and/or its affiliates.
28
29Oracle is a registered trademark of Oracle Corporation and/or its
30affiliates. Other names may be trademarks of their respective
31owners.
32
33Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
34
35mysql> show databases;
36+--------------------+
37| Database |
38+--------------------+
39| information_schema |
40| mysql |
41| performance_schema |
42| sys |
43+--------------------+
444 rows in set (0.05 sec)
45
46mysql> create database lhrdb;
47Query OK, 1 row affected (0.04 sec)
48
49mysql> show databases;
50+--------------------+
51| Database |
52+--------------------+
53| information_schema |
54| lhrdb |
55| mysql |
56| performance_schema |
57| sys |
58+--------------------+
595 rows in set (0.00 sec)