In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
The editor will share with you how to solve the Packet for query is too large problem in MySQL. I hope you will get something after reading this article. Let's discuss it together.
Problem description:
Error message:
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1354 > 1024). You can change this value on the server
By setting the max_allowed_packet' variable
MySQL limits the packet size accepted by Server based on the configuration file. Sometimes the size of the packet when inserting, updating, or querying is limited by the max_allowed_packet parameter, causing the operation to fail.
View the max_allowed_packet parameters:
Execute on the client:
Show VARIABLES like'% max_allowed_packet%'
The results are as follows:
+-+-+ | Variable_name | Value | +-+-+ | max_allowed_packet | 1024 | + -+
Modify method:
1. Modify the configuration file
You can edit my.cnf to modify it (my.ini under windows), and modify it in the [mysqld] section or the server configuration section of mysql.
Max_allowed_packet = 20m
If you can't find my.cnf, you can go through
Mysql-- help | grep my.cnf
To find the my.cnf file.
Under linux, the file is under / etc/.
2. Modify in the mysql command line
Set global max_allowed_packet = 2 "1024" 1024 "10 / / the value here is the number of bytes, and here it is changed to 20m, so you need to log in to the client again to work.
Note: after the client is modified with the command, it can only work temporarily, and the original value will be restored after restarting MYSQL.
The solution to the error of mysql reporting Packet for query is too large (1040 > 1024) under Linux
The project has been running normally, these days suddenly has been prompting query error, look at the log found prompt Packet for query is too large (1040 > 1024). You can change this value on the server by setting the max_allowed_packet' variable. Mistake. Baidu has a solution and records the process of the solution.
1. Reason
The packet returned by the query database is too large and exceeds the default value.
Log in to mysql, enter the command in the console to query the default max_allowed_ packet value, and find that it is only 1024
Show VARIABLES like'% max_allowed_packet%'
two。 Modify the default maximum allowable packet size
2.1 method 1: command mode
(1)。 Enter the following command under the mysql console to set the max_allowed_packet to 20m
Set global max_allowed_packet = 20,1024,1024
(2)。 Exit mysql, restart the mysql service, and log in to myql to check whether the max_allowed_packet has been modified successfully.
Show VARIABLES like'% max_allowed_packet%'
2.2.2.Modification of configuration file my.cnf mode
(1) enter the following command under the MySQL console to edit my.cnf
Sudo vi / etc/mysql/my.cnf
(2)。 Add under [mysqId]
Max_allowed_packet = 20m
2.2 exit edit mode and restart mysql, as shown in (2) of 2.1
3. Note
After configuring the query max_allowed_packet, it is found that it is 16777216, which is actually 16 "1024" 1024, which is not the expected 20m, so I checked again that the server memory capacity may not be enough, because java takes up a lot, so mysql may automatically reset the parameters. So in some cases, you may have changed the max_allowed_packet parameter at that time, and after a period of time, the mysql automatically reset the parameter to the default 1024, and the same error occurred again.
After reading this article, I believe you have a certain understanding of "how to solve the Packet for query is too large problem in MySQL". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.