Problem description:
When using navicat in the host to connect to mysql in the virtual machine, the following error message appears:
Solution:
1. First use the docker ps command to check the running container and make sure that the mysql we want to connect to has been started. If not, use docker start Command startup (the result shown in the picture below indicates that a mysql has been started)
2. Then run the docker exec -it b30062adc08c /bin/bash commandEnter the mysql container
3. Then enter the mysql -u root -p command, then enter your own password, and finally enter the update password statement: ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY ' 123456';
4. Finally, restart mysql and use navicat to connect successfully
Recommended tutorial:docker tutorial
The above is the detailed content of What to do if the connection to mysql in docker fails. For more information, please follow other related articles on the PHP Chinese website!