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

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
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了,怀疑是规格太小导致,等升级下实例规格看看

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
29天前
|
关系型数据库 MySQL Linux
Packet for query is too large (4467936 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable
【10月更文挑战第15天】解决Packet for query is too large (4467936 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable
46 1
|
3月前
|
JSON PHP 数据格式
PHP Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)
PHP Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes)
67 2
|
6月前
|
SQL 关系型数据库 MySQL
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
96 0
|
6月前
What value should kernel parameter AIO-MAX-NR be set to ?
What value should kernel parameter AIO-MAX-NR be set to ?
60 0
|
Java 应用服务中间件
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
161 0
|
6月前
|
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
52 0
|
关系型数据库 MySQL 数据安全/隐私保护
被我误解的max_connect_errors
谈谈被我误解的max_connect_errors
被我误解的max_connect_errors
|
关系型数据库 MySQL Linux
MySQL:Got a packet bigger than ‘max_allowed_packet‘ bytes
我们往MySQL导入数据的时候,当数据量过大的时候,就会报错,这是因为允许的最大数据超出了我们的默认设置,所以我们需要修改MySQL的默认设置
177 0
MySQL:Got a packet bigger than ‘max_allowed_packet‘ bytes
|
Java 应用服务中间件
The field file exceeds its maximum permitted size of 1048576 bytes.
The field file exceeds its maximum permitted size of 1048576 bytes.
|
缓存 关系型数据库 MySQL
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
249 0
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案