Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
787 views
in Technique[技术] by (71.8m points)

docker - Can't connect to MySQL server container from the MySQL command line client container; ERROR 2003 (HY000) (113)

Trying the official mysql docker and using the advice here to setup a user-defined network. I get an error related to the routing between the containers (113). when running the client container I am using the root password set in first command.

[liran@localhost ~]$ docker run --network mysql-net --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest
497ff8aa24ce904230170a51649df8eb96de638baec90ed3510ec3d420f7c7e6
[liran@localhost ~]$ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
497ff8aa24ce        mysql:latest        "docker-entrypoint.s…"   9 seconds ago       Up 8 seconds        3306/tcp, 33060/tcp   some-mysql
[liran@localhost ~]$ docker run --network mysql-net -it --rm mysql:latest mysql -hsome-mysql -uroot -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on 'some-mysql' (113)
[liran@localhost ~]$ 

The server seems ok:

[liran@localhost ~]$ docker exec -it some-mysql mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> exit
Bye
[liran@localhost ~]$ grep -i "ready for start up" <(docker logs some-mysql 2>&1)
2021-01-09 19:56:03+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
[liran@localhost ~]$ 
question from:https://stackoverflow.com/questions/65647099/cant-connect-to-mysql-server-container-from-the-mysql-command-line-client-conta

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...