search
HomeOperation and MaintenanceDockerWhat to do if the connection to mysql in docker fails

What to do if the connection to mysql in docker fails

Problem description:

When using navicat in the host to connect to mysql in the virtual machine, the following error message appears:

What to do if the connection to mysql in docker fails

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)

What to do if the connection to mysql in docker fails

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';

What to do if the connection to mysql in docker fails

4. Finally, restart mysql and use navicat to connect successfully

What to do if the connection to mysql in docker fails

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does Docker relate to serverless computing?How does Docker relate to serverless computing?Jul 23, 2025 am 01:36 AM

Dockerandserverlesscomputingservedifferentpurposesbutcancomplementeachother.1.Dockerisacontainerizationplatformofferingcontroloverruntimeenvironments,whileserverlessfocusesonevent-drivenfunctionswithoutinfrastructuremanagement.2.CloudproviderslikeAWS

How to check Docker version?How to check Docker version?Jul 23, 2025 am 01:26 AM

Use docker--version to view the client version; 2. Use dockerversion to get the detailed information of the client and server; 3. Use dockerversion--format'{{.Server.Version}}' to get only the server version in the script, which is suitable for automation scenarios. The above commands can be used without additional configuration.

How to restart a Docker container?How to restart a Docker container?Jul 23, 2025 am 01:02 AM

Use dockerrestart to restart existing containers; 2. Docker will send SIGTERM signal first and wait for the default for 10 seconds, and then send SIGKILL for forced termination; 3. It is suitable for updating environment variables, mount volumes or reloading containers after configuration; 4. You can use dockerps-a to check the container name, --time=N to customize the waiting time, and use dockercomposerestart for Compose project; 5. Note that restarting does not apply to the new layer of the mirror or Dockerfile changes. When rebuilding, docker-composeup--build or create a new container to end.

How does Docker networking work?How does Docker networking work?Jul 23, 2025 am 12:34 AM

Dockernetworkingworksbyusingvirtualnetworkstoconnectcontainers,allowingthemtocommunicatewitheachotherandtheoutsideworld.1)ThedefaultbridgenetworkallowscommunicationviaIPaddressesbutnothostnames,whileuser-definednetworksenablehostnameresolution.2)Cont

How do you use Docker with Google Cloud Platform (GCP)?How do you use Docker with Google Cloud Platform (GCP)?Jul 22, 2025 am 03:40 AM

TouseDockerwithGCP,youbuildaDockerimage,pushittoGoogleContainerRegistry(GCR),anddeployitusingserviceslikeCloudRunorGoogleKubernetesEngine(GKE).1.CreateaDockerimagelocallywithaDockerfile,exposethecorrectport,andtestit.2.PushtheimagetoGCRafterenablingt

How do you configure Docker Content Trust?How do you configure Docker Content Trust?Jul 22, 2025 am 03:26 AM

DockerContentTrust(DCT)isasecurityfeaturethatensuresonlytrustedimagesarepulledorrunbyverifyingpublishersignatures.1.ItisenabledbysettingtheenvironmentvariableexportDOCKER_CONTENT_TRUST=1,whichmakesDockerrefuseunsignedimages.2.Nospecialtoolsareneeded,

How can containers communicate with each other on the same network?How can containers communicate with each other on the same network?Jul 22, 2025 am 03:12 AM

ContainersonthesameDockernetworkcancommunicateviacontainernamesbecauseDockerprovidesaninternalDNSserver.1.Createacustomnetworkwithdockernetworkcreate.2.Attachcontainerstothenetworkusing--networkwhenrunningthem.3.Containerscanthenresolveeachotherbynam

How do you connect containers to a specific Docker network?How do you connect containers to a specific Docker network?Jul 22, 2025 am 01:50 AM

ToconnectcontainerstoaDockernetwork,useDockerCLIcommands.1.First,createoridentifyanexistingnetworkusingdockernetworkcreateordockernetworkls.2.Connectarunningcontainerwithdockernetworkconnect.3.Assignanetworkwhenstartinganewcontainerusingthe--networkf

See all articles

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function