本地 MySQL 是 docker-composer 统一部署的,之前一直都是正常使用,但是一次 CPU 爆满电脑意外关机重启后,发现本地连不上 MySQL 了,远程的 ssh 是正常的,看报错是 mysql 连接套接字问题,于是我做了下面的尝试:
1.重启 MySQL 容器服务 2.重建 docker-composer 所有镜像 3.尝试 exec 到 MySQL 容器 bash 连接
结果发现还是连不上,有几处比较关键的报错提示,我这里贴一下:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"
比较奇怪的一点,我发现 mysql 一直反复重启,一直在 Restarting 这个状态
docker_mysql_1 docker-entrypoint.sh mysqld Restarting
各位大佬们帮帮手吗 我太难顶了鸭( ps:docker 小白,仅仅是喜欢 docker 部署开发环境,其他没研究)
1
zhuzhibin OP 🚘🚘🚘🚘🚘🚘🚘🚘🚘🚘🚘🚘🚘🚘🚘
|
2
arjen 2020-04-11 13:14:28 +08:00 via Android
看一下 docker-mysql 的 log, docker logs container_id
|
3
zhuzhibin OP @arjen
``` ➜ docker docker logs 8c769a2e2ac4 2020-04-11 04:42:22+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:42:24+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:42:24+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:42:36+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:42:38+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:42:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:42:49+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:42:51+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:42:51+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:01+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:03+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:43:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:10+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:12+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:43:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:19+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:43:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:32+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' 2020-04-11 04:43:32+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. 2020-04-11 04:43:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started. ``` |
5
weiqipeng 2023-09-10 21:46:08 +08:00
解决了吗。我用 docker 装的 mysql 自己配置了 my.cnf 也是这情况
|