Problem description: Error message:
MySQL will limit the size of the data packet accepted by the Server according to the configuration file. Sometimes the size of the data packet during insert, update or query is limited by the max_allowed_packet parameter, causing the operation to fail. View the max_allowed_packet parameter: Execute on the client: show VARIABLES like '%max_allowed_packet%'; The results are as follows: +--------------------+------------+ | Variable_name | Value | +--------------------+-------------------+ | max_allowed_packet | 1024 | +--------------------+-------------------+ Modification method: 1. To modify the configuration file, you can edit my.cnf (my.ini under Windows) and modify it in the [mysqld] section or the mysql server configuration section. If my.cnf cannot be found, you can Go find the my.cnf file. In Linux, the file is located in /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. If it is changed to 20M, you need to log in to the client again to take effect. Note: After the client uses the command to modify, it will only take effect temporarily. After restarting MYSQL, the original value will be restored. Solution to the error "Packet for query is too large (1040 > 1024)" reported by MySQL under Linux The project had been running normally before, but suddenly in the past few days it kept prompting query errors. I looked at the logs and found that it prompted Packet for query is too large (1040 > 1024). You can change this value on the server by setting the max_allowed_packet' variable. error. I searched Baidu for the solution and recorded the solution process. 1. Reasons The data packet returned by the query database is too large and exceeds the default value. show VARIABLES like '%max_allowed_packet%'; 2. Modify the default maximum allowed packet size 2.1 Method 1: Command method (1). Enter the following command in the MySQL console to set max_allowed_packet to 20M
(2) Exit MySQL, restart the MySQL service, and then log in to MySQL to check whether max_allowed_packet has been modified successfully.
2.2 Method 2: Modify the configuration file my.cnf
(2). Add below [mysqId]
2.2 Exit edit mode and restart MySQL. Follow the steps in 2.1 (2) 3. Note After configuration, I queried max_allowed_packet and found that it was 16777216, which is actually 16*1024*1024, not the expected 20M. So I checked again and found that the server memory capacity might be insufficient, because Java occupies a lot of it, so MySQL might automatically reset the parameters. So in some cases, it may be that after you changed the max_allowed_packet parameter, MySQL automatically reset the parameter to the default 1024 after a while, and the same error occurred again. |
<<: How to configure Nginx to split traffic based on the last segment of the request IP
>>: Angular performance optimization: third-party components and lazy loading technology
When we write code, we often need to know the dif...
This article shares the specific code of Javascri...
Server placement It is recommended to use cloud s...
Preface Recently, I have been busy dealing with s...
The image can be saved on hub.docker.com, but the...
Table of contents When declaring multiple variabl...
Table of contents 1. Bootstrap Grid Layout 2. Ver...
<meta http-equiv="x-ua-compatible" co...
I recently encountered a strange thing when debug...
Table of contents Preface introduce 1. Mechanism ...
How to configure custom path aliases in Vue In ou...
In actual work or interviews, we often encounter ...
Static files Nginx is known for its high performa...
1. Introduction CentOS8 system update, the new ve...
Sophie Hardach Clyde Quay Wharf 37 East Soapbox Rx...