How to install MySQL8.0 in Docker
This article is about how to install MySQL 8.0 in Docker. Xiaobian thinks it is very practical, so share it with everyone to learn. I hope you can gain something after reading this article. Let's not say much. Let's take a look at it together with Xiaobian.
1. Docker repository search mysql
docker search mysql
2. Docker warehouse pulls mysql8.0
docker pull mysql:8.0
Remarks:
docker pull mysql //default pull latest version
3. Check whether the local repository image is downloaded successfully.
docker images mysql:8.0
4. Install and run mysql8.0 container
docker run -p 3307:3306 --name mysql8.0 -e MYSQL_ROOT_PASSWORD=root -d mysql:8.0
Remarks:
-p Map the port of the local host to the docker container port (port 3307 is used because port 3306 of the local host is already occupied by other versions)
--name Container name naming-
e Configuration information, configure root password
-d Mirror name
5. Check the operation of mysql8.0 container
docker ps
6. Docker login mysql
docker exec -it mysql8.0 bash
mysql -uroot -p
7. Use the client connection tool (navicat) to remotely log in to mysql
Error: navicat does not support caching_sha_password encryption method
Reason: mysql8.0 uses a new password encryption method: caching_sha_password
Solution: Change to the old encryption method (mysql_native_password) and reset the password
* select host,user,plugin from user;
* alter user 'root'@'%' identified with mysql_native_password by 'root';
8. Use the client connection tool (navicat) to log back into mysql remotely
9. Postscript (commonly used 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//Pull latest image by default
docker images //View locally downloaded images
docker ps //View running containers
docker ps -a //View all containers (including run, stop, exited)
docker container ls //View running containers
docker rm Container ID //Only containers that are not running can be deleted
docker rm -f Container ID //can delete running containers
docker run -p Local host port number: Kubernetes Engine port number--name Container name [-e Configuration information modification] -d Image name
docker start Container ID //Start Container
docker stop Container ID //Terminate container
docker rmi image name orID //remove image
The above is how to install MySQL 8.0 in Docker, Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.