The configuration method of max_allowed_packet parameter in mysql (to avoid writing or updating Big Data) MySQL limits the size of data packets received by the Server according to the configuration file. Sometimes large inserts and updates are limited by the max_allowed_packet parameter, leading to write or update failure.
View the current configuration:
Show VARIABLES like '% max_allowed_packet % ';
The result is as follows:
+ -------------------- + --------- +
| Variable_name | Value |
+ -------------------- + --------- +
| Max_allowed_packet| 1048576 |
+ -------------------- + --------- +
The preceding description shows the current configuration: 1 M.
Modification method
1. modify the configuration file
You can edit my. cnf (my. ini in windows) and modify it in the [mysqld] section or mysql server configuration section.
Max_allowed_packet = 20 M
If you cannot find my. cnf, you can use
Mysql -- help | grep my. cnf
Find the my. cnf file.
In linux, the file is in/etc.
2. modify it in the mysql command line
Run the following command in the mysql command line:
Set global max_allowed_packet = 2*1024*1024*10
Then exit the command line, restart the mysql service, and then enter.
Show VARIABLES like '% max_allowed_packet % ';
Check whether max_allowed_packet is successfully edited.
Note: If this value is set too small, writing to the database fails if a single record exceeds the limit, and writing to subsequent records also fails.