【问题标题】:MariaDB in docker said - Error Code: 2013. Lost connection to MySQL server during querydocker 中的 MariaDB 说 - 错误代码:2013。在查询期间失去与 MySQL 服务器的连接
【发布时间】:2020-12-04 02:19:26
【问题描述】:

我用一些重要的选项启动 mariadb docker

--connect_timeout  43200 --max_allowed_packet 1073741824 --net_read_timeout 100 --innodb_buffer_pool_size 64M

我的 wokrbench 也增加了超时时间

但经过大量实验后,我仍然收到丢失的连接。

下面我放置了我的 SQL 命令产生的错误。这是另一个工作的 mariadb 服务器的转储,但没有 docker。

DROP TABLE IF EXISTS `AspNetUsers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `AspNetUsers` (
  `Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
  `UserName` varchar(256) CHARACTER SET utf8mb4 DEFAULT NULL,
  `NormalizedUserName` varchar(256) CHARACTER SET utf8mb4 DEFAULT NULL,
  `Email` varchar(256) CHARACTER SET utf8mb4 DEFAULT NULL,
  `NormalizedEmail` varchar(256) CHARACTER SET utf8mb4 DEFAULT NULL,
  `EmailConfirmed` tinyint(1) NOT NULL,
  `PasswordHash` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `SecurityStamp` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `ConcurrencyStamp` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `PhoneNumber` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `PhoneNumberConfirmed` tinyint(1) NOT NULL,
  `TwoFactorEnabled` tinyint(1) NOT NULL,
  `LockoutEnd` datetime(6) DEFAULT NULL,
  `LockoutEnabled` tinyint(1) NOT NULL,
  `AccessFailedCount` int(11) NOT NULL,
  `DiscordId` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `DiscordEnabled` tinyint(1) NOT NULL,
  `DiscordServerId` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `IsGoogleAuthenticatorEnabled` tinyint(1) NOT NULL,
  `GoogleAuthenticatorSecretKey` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `IPAddress` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `UserAgent` longtext CHARACTER SET utf8mb4 DEFAULT NULL,
  `ResetDone` tinyint(1) NOT NULL,
  `APIKey` char(36) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`Id`),
  UNIQUE KEY `UserNameIndex` (`NormalizedUserName`),
  KEY `EmailIndex` (`NormalizedEmail`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

这是容器的日志

2020-12-04  1:49:02 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2020-12-04  1:49:02 0 [Note] InnoDB: Initializing buffer pool, total size = 67108864, chunk size = 67108864
2020-12-04  1:49:02 0 [Note] InnoDB: Completed initialization of buffer pool
2020-12-04  1:49:02 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-12-04  1:49:02 0 [Note] InnoDB: 128 rollback segments are active.
2020-12-04  1:49:02 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-12-04  1:49:02 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-12-04  1:49:02 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-12-04  1:49:02 0 [Note] InnoDB: 10.5.8 started; log sequence number 67060; transaction id 71
2020-12-04  1:49:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-12-04  1:49:02 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-12-04  1:49:02 0 [Note] InnoDB: Buffer pool(s) load completed at 201204  1:49:02
2020-12-04  1:49:02 0 [Note] Server socket created on IP: '::'.
2020-12-04  1:49:02 0 [Warning] 'proxies_priv' entry '@% root@f29788dfc1fd' ignored in --skip-name-resolve mode.
2020-12-04  1:49:02 0 [Note] Reading of all Master_info entries succeeded
2020-12-04  1:49:02 0 [Note] Added new Master_info '' to hash table
2020-12-04  1:49:02 0 [Note] mysqld: ready for connections.
Version: '10.5.8-MariaDB-1:10.5.8+maria~focal'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2020-12-04  4:00:53 4 [Warning] Aborted connection 4 to db: 'YYYYYYY' user: 'root' host: 'XX.XX.XX.XX' (Got timeout reading communication packets)

有人了解会发生什么吗?

【问题讨论】:

  • 我们可以查看您的 docker 文件/docker-compose.yml 吗?您收到的确切错误/丢失连接消息是什么?
  • innodb_buffer_pool_size 64M 太小了。你有多少内存。如果可能,从 1G 开始。显示来自 docker 容器的日志。
  • @mikey,我根本无法通过 YML 启动 maria db,只能通过命令行,如果我通过 YML 启动,我总是收到 [ERROR] mysqld: Got error 'Can't open file' when试图使用 aria 控制文件 '/var/lib/mysql/aria_log_control' [错误] InnoDB:innodb_system 数据文件 'ibdata1' 必须是可写的 [错误] 插件 'InnoDB' 注册为存储引擎失败。
  • @danblack 我从 docker 开始。本机整机有4GB RAB

标签: mysql docker timeout mysql-workbench


【解决方案1】:

我找到了另一种在 dockerizing mariadb 服务器中运行 SQL 脚本的解决方案。我在同一台机器的命令行中运行相同的脚本:

sudo docker exec -i mariadb-server2 sh -c 'exec mysql -uroot -p"xxxxxxxx"' < /home/wwwadmin/tst1.sql

为什么这个脚本不能通过 docker 网络和 Workbench 远程工作我仍然不明白。有趣的是,我需要上传一个包含大量表和数据的大型数据库,但只有几个脚本会引发此错误“错误代码:2013。在查询期间丢失与 MySQL 服务器的连接”。 99.9% 的 sql 脚本运行时没有此错误。

【讨论】:

    猜你喜欢
    • 2019-05-29
    • 2012-05-20
    • 2017-05-05
    • 1970-01-01
    • 2018-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多