Today we continue with the last post on installing and running MySQL. It is recommended to read the first article: Installing Docker for Windows

A view of the MySQL version

If you want to know which versions of the MySQL image are available, you need to check out the Docker Hub.

The address is as follows: https://hub.docker.com/r/libr…

Mysql > select * from mysql. mysql > select * from mysql. mysql

The command is as follows:

Docker pull image name: version number

Open a command window and type

Docker pull mysql: 8.0

Wait a few minutes, then type the following command to view the image

docker images

3. Start MySQL service

The command is as follows:

Docker run --name mysql8.0-e MYSQL_ROOT_PASSWORD= 123456-d-p 23306:3306 mysql:8.0

Explain the meaning of the above command

Mysql8.0-e MYSQL_ROOT_PASSWORD=123456 // Configure the environment variable mysql8.0-e MYSQL_ROOT_PASSWORD=123456 Specify the root user password is 123456 - d / / start whether the background, the default false - p, 23306:3306 out of 23306 / / 3306 port mapping to access mysql: 8.0 / / the name of the mirror

Allows the client to log in

After the completion of the third step, a Docker container is installed. We connect to the database with the client and find an error.

The main reason is that the version of the authentication plug-in required by the MySQL server is inconsistent with that of the client.

Mysql8.0/bin/bash = mysql8.0/bash = mysql8.0/bin/bash = mysql8.0/bash = mysql8.0/bash Mysql -uroot-p 123456 mysql -uroot-p 123456 mysql -uroot-p 123456 mysql -uroot-p 123456 mysql -uroot-p 123456

The plugin used by root is caching_sha2_password. The plugin used by root is caching_sha2_password.

Caching_sha2_password is the 8.0 default authentication plug-in. You must use the client version that supports this plug-in. One is to update the client, and the other is to change the plug-in authentication to mysql_native_password. Let’s take a look at the second.

// change the password from root to 'root'. Second: Encode the new password with mysql_native_password. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; // FLUSH PRIVILEGES;

This is done, and the client can log in normally.

Five Docker common commands

2. Docker Run // Generate a running instance of the container 3. Docker Stop // Stop the container 4. Docker RM Container // Deleting the container 5. Docker Docker exec-it container name /bin/bash // docker exec-it container name /bin/bash // docker exec-it container name /bin/bash // docker exec-it container name /bin/bash // docker exec-it container name /bin/bash // 9. Docker ps // Shows all containers running 10. Docker ps -a // Shows all containers (including stopped) 11

If this article has been helpful, please keep an eye on thumb up


Welcome to pay attention to my public account < sentiment IT>, push technical articles for everyone to learn and reference every day.