1. Pull the mirror

Docker pull mysql: 8.0.23

  1. Check whether the pull is successful

docker images

  1. Do not mount containers on local disks

Sudo docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:8.0.23

-p: port mapping. Port 3306 of the host is mapped to port 3306 of the container. -d: Running the container in the background to ensure that the container continues to run after you exit the terminal. Create docker mysql local disk mount directory, check docker mysql copy mysql configuration file to local directory

mkdir -pv /usr/app/docker/mysql/{conf,logs,data,mysql-files}

[root@helpMachine ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES aab3ae06b416 mysql "Docker - entrypoint. S..." 7 days ago Up 32 hours 0.0.0.0:3306->3306/ TCP, 33060/ TCP mysqlJiang

docker cp aab3ae06b416:/etc/mysql/my.cnf /usr/app/docker/mysql/conf

5. Create a Docker container

Docker run -d --name mysqlJiang --restart=always --net mynetwork -- IP 172.18.0.6 -p 3306:3306 -v /usr/app/docker/mysql/conf:/etc/mysql/conf.d \ -v /usr/app/docker/mysql/logs:/var/log/mysql \ -v /usr/app/docker/mysql/data:/var/lib/mysql \ -v /usr/app/docker/mysql/mysql-files:/var/lib/mysql-files/ \ -e MYSQL_ROOT_PASSWORD=root \ -d mysql

[root@helpMachine docker]# docker ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED         STATUS         PORTS                                                      NAMES
aab3ae06b416   mysql                           "Docker - entrypoint. S..."   5 seconds ago   Up 3 seconds   0.0. 0. 0:3306->3306/tcp, 33060/tcp                          mysqlJiang
8529d3995214   canal/canal-server              "/ alidata/bin/main. S..."   2 days ago      Up 2 days      9100/tcp, 11110/tcp, 11112/tcp, 0.0. 0. 0:11111->11111/tcp   canal-server
0c4f31737d22   probablyfine/flume:2.0. 0        "start-flume"            6 days ago      Up 2 days                                                                 flume-test
9f0ac325b356   apachepulsar/pulsar-dashboard   "/pulsar/start.sh"       6 days ago      Up 2 days      0.0. 0. 0:8081->80/tcp                                       apachePulsar-dashboard
9f75b7f33707   apachepulsar/pulsar:2.42.       "Bin/pulsar standalo..."   6 days ago      Up 2 days      0.0. 0. 0:6650->6650/tcp, 0.0. 0. 0:8080->8080/tcp             vigilant_lewin
[root@helpMachine docker]# docker logs -f aab3ae06b416
2021-03-25 01:51:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.023.-1debian10 started.
2021-03-25 01:51:56+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-03-25 01:51:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.023.-1debian10 started.
2021-03-25 01:51:56+00:00 [Note] [Entrypoint]: Initializing database files
mysqld: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.
2021-03-25T01:51:56.822816Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.023.) initializing of server in progress as process 43
2021-03-25T01:51:56.832556Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-03-25T01:51:57.708923Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-03-25T01:51:59.282302Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2021-03-25 01:52:02+00:00 [Note] [Entrypoint]: Database files initialized
2021-03-25 01:52:02+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.
2021-03-25T01:52:03.165377Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.023.) starting as process 88
2021-03-25T01:52:03.307737Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-03-25T01:52:03.974253Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-03-25T01:52:04.135265Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2021-03-25T01:52:04.322587Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-03-25T01:52:04.322787Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-03-25T01:52:04.324137Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-03-25T01:52:04.345179Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.
2021-03-25 01:52:04+00:00 [Note] [Entrypoint]: Temporary server started.
mysql: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
mysql: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.

2021-03-25 01:52:09+00:00 [Note] [Entrypoint]: Stopping temporary server
mysqladmin: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.
2021-03-25T01:52:09.566311Z 10 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.023.).
2021-03-25T01:52:10.865083Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.023.)  MySQL Community Server - GPL.
2021-03-25 01:52:11+00:00 [Note] [Entrypoint]: Temporary server stopped

2021-03-25 01:52:11+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

mysqld: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.
2021-03-25T01:52:11.844977Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.023.) starting as process 1
2021-03-25T01:52:11.854103Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-03-25T01:52:12.367605Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-03-25T01:52:12.545614Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '... ' port: 33060.socket: /var/run/mysqld/mysqlx.sock
2021-03-25T01:52:12.675237Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-03-25T01:52:12.675468Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-03-25T01:52:12.679057Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-03-25T01:52:12.700492Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
Copy the code
[root@helpMachine docker]# docker exec -it aab3ae06b416 /bin/bash
root@aab3ae06b416:/#
root@aab3ae06b416:/#
root@aab3ae06b416:/# mysql -uroot -proot
mysql: [Warning] Skipping '! includedir /etc/mysql/conf.d/' directive as maximum include recursion level was reached in file /etc/mysql/conf.d/my.cnf at line 32.
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.023. MySQL Community Server - GPL

Copyright (c) 2000.2021, Oracle and/or its affiliates.

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 host,user,plugin,authentication_string frommysql.user; +-----------+------------------+-----------------------+---------------------------------------------------------------- --------+ | host | user | plugin | authentication_string | +-----------+------------------+-----------------------+---------------------------------------------------------------- --------+ | % | canal | mysql_native_password | *E3619321C1A937C46A0D8BD1DAC39F93B27D4458 | | % | root | caching_sha2_password | $A$005$b2; o~`65U|napE>L.QjY2XLddFrUT/uqRciIsI5zEACo3jQS2AGzHYwC8XA07 | | localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.sys  | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | root |  caching_sha2_password | $A$005$ e" }x/3T^; ! y% rB10XeOqUv0P.T8CcjwhoFOhF.Y2D.Ol2U.ZdIA0v39 | +-----------+------------------+-----------------------+---------------------------------------------------------------- --------+ 6 rows in set (0.08 SEC) mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; Query OK, 0 rows affected (0.00 SEC) mysql>Copy the code