mysql 宿主机没有办法访问的问题
docker 中 mysql 的服务正常
root@Temak:/# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fa56afd0a5c5 mysql:8.0.20 "docker-entrypoint.s…" 57 minutes ago Up 14 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql8
端口 3306 也没有被占用
root@Temak:/# sudo netstat -tuln | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
宿主机
root@Temak:/# telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
但是宿主机访问 docker 中的 mysql
root@Temak:/# mysql -u root -p -h 127.0.0.1 -P 3306
Enter password:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
docker 中 mysql 的日志:
2025-01-04T02:18:41.937188Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
2025-01-04T02:18:41.948132Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-01-04T02:18:42.188458Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-01-04T02:18:42.302034Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2025-01-04T02:18:42.341277Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2025-01-04T02:18:42.342798Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2025-01-04T02:18:42.359459Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.20' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
请问大神如何解决宿主机访问 docker 中的 mysql