Environment: macOS_CETALINA_10.15.1, Mysql8.0.18, docker_2.0.0.3
1, Docker warehouse search mysql
docker search mysql
Copy the code
2, Docker repository pull mysql8.0
Docker pull mysql:8.0 Note: Docker pull mysql // pulls the latest version by defaultCopy the code
3. Check whether the image file is downloaded successfully
Docker images mysql: 8.0Copy the code
4, install and run mysql8.0 container
Docker run -p 3307:3306 --name mysql8.0-e MYSQL_ROOT_PASSWORD=root -dMysql :8.0 Note: -p maps localhost port to docker container port (docker container port 3307 is used because port 3306 has been used by other versions) --name Specifies the container name-eConfigure the root password-dName of the mirrorCopy the code
5. Check the mysql8.0 container running status
docker ps
Copy the code
6, docker login mysql
docker exec -it mysql8.0 bash
mysql -uroot -p
Copy the code
7. Use navicat to log in to mysql remotely
Navicat does not support the caching_sha_password encryption mode. Cause: mysql8.0 uses the new password encryption mode: caching_sha_password Solution: * select host,user,plugin from user; * mysql_native_password; * alter user'root'@The '%' identified with mysql_native_password by 'root';
Copy the code
8. Use navicat to remotely log in to mysql again
9. Postscript (common docker command)
Docker search Image name // Search image docker pull Image name: version number // Pull the image of the corresponding version docker pull image name // Default pull the latest image docker images // View the downloaded image Docker ps // View the running container Docker ps-a// Delete only the docker rm that is not in the running state-fDocker run -p localhost port number: localhost port number --name Localhost name [-eModifying configuration information]-dDocker start Container ID // Start container docker stop container ID // Stop container docker RMI image name orID // Delete the imageCopy the code