ERROR 2020 (HY000): Got packet bigger than 'max_allowed_packet' bytes

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 今天在测试环境发生了貌似怪异的报错,表结构如下: CREATE TABLE `test` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `step` bigint(20) NOT NULL COMMENT 'step', `da.

今天在测试环境发生了貌似怪异的报错,
表结构如下:

CREATE TABLE `test` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `step` bigint(20) NOT NULL COMMENT 'step',
  `data` longtext COMMENT 'step data',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1778606 DEFAULT CHARSET=utf8 COMMENT='test'

要查询一条数据

select char_length(data) from test where id=1;

结果却是:

mysql> ERROR 2020 (HY000): Got packet bigger than 'max_allowed_packet' bytes

而实际情况是:

mysql> select length(data),char_length(data) from test where id=1;
+--------------+-------------------+
| length(data) | char_length(data) |
+--------------+-------------------+
|     22270339 |          22270339 |
+--------------+-------------------+
1 row in set (0.12 sec)

为什么已经把max_allowed_packet设置成最大了,还是报ERROR 2020 (HY000)错啊?

mysql> show global variables like "max_allowed_packet";
+--------------------+------------+
| Variable_name      | Value      |
+--------------------+------------+
| max_allowed_packet | 1073741824 |
+--------------------+------------+
1 row in set (0.00 sec)

即使里面存的中文utf8占3个字节,22270339*3<1073741824啊,忽然灵机一动,看了

mysql> show global variables like "innodb_buffer_pool_size";
+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| innodb_buffer_pool_size | 880803840 |
+-------------------------+-----------+
1 row in set (0.00 sec)

mysql> select 880803840/(1024*1024*1024.0);                                                                                                                                               +------------------------------+
| 880803840/(1024*1024*1024.0) |
+------------------------------+
|                       0.8203 |
+------------------------------+
1 row in set (0.00 sec)

max_allowed_packet已经大于innodb_buffer_pool_size了,怀疑是规格太小导致,等升级下实例规格看看

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
SQL 关系型数据库 MySQL
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
19 0
|
8月前
|
Java 应用服务中间件
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
79 0
|
1月前
|
SQL 关系型数据库 MySQL
[ERR] 2006 - MySQL server has gone away,Got a packet bigger than 'max_allowed_packet' bytes
[ERR] 2006 - MySQL server has gone away,Got a packet bigger than 'max_allowed_packet' bytes
32 0
|
10月前
|
Java Spring
The field file exceeds its maximum permitted size of 1048576 bytes 文件上传大小受到限制,报错!!
The field file exceeds its maximum permitted size of 1048576 bytes 文件上传大小受到限制,报错!!
154 0
【WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, st】
【WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, st】
154 0
|
Java 应用服务中间件
The field file exceeds its maximum permitted size of 1048576 bytes.
The field file exceeds its maximum permitted size of 1048576 bytes.
|
关系型数据库 MySQL Linux
MySQL:Got a packet bigger than ‘max_allowed_packet‘ bytes
我们往MySQL导入数据的时候,当数据量过大的时候,就会报错,这是因为允许的最大数据超出了我们的默认设置,所以我们需要修改MySQL的默认设置
122 0
MySQL:Got a packet bigger than ‘max_allowed_packet‘ bytes
|
关系型数据库 MySQL 数据安全/隐私保护
被我误解的max_connect_errors
谈谈被我误解的max_connect_errors
被我误解的max_connect_errors
|
SQL 关系型数据库 MySQL
mysql的 max_allowed_packet 和 max_connections
mysql的 max_allowed_packet 和 max_connections
188 0
|
缓存 关系型数据库 MySQL
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
189 0
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案