How can I know the maximum length of SQL statements allowed by mysql?
The max_allowed_packet of mysql roughly indicates the maximum size of the SQL statement that can be executed. The max_allowed_packet Protocol is limited to 1 GB. The value should be a multiple of 1024, not a forward-down to the nearest multiple.
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) method 1
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.
2) method 2
Enter mysql server
Run in mysql Command Line
Set global max_allowed_packet = 2*1024*1024*10
Close the mysql server Client and run the following command again to check whether the value of max_allowed_packet has been modified successfully.
Show VARIABLES like '% max_allowed_packet % ';