The contents of a text file are typically imported into the database through MySQL's "Load data local infile" statement.
It's going to be fast, but today it's found that if the text is larger than 1M, an exception occurs: "Packets larger than max_allowed_packet are not allowed"
One of MySQL's system parameters: Max_allowed_packet, whose default value is 1048576 (1M),
Query: Show VARIABLES like '%max_allowed_packet% ';
Modify the value of this variable: "Max_allowed_packet = 1M" In the [Mysqld] section of the My.ini file in the MySQL installation directory, such as 4M (if there is no such line, add a line), save, and restart the MySQL service. You can now load more than 1M files.
MySQL Max_allowed_packet queries and modifications
Mysqlwindows
Depending on the profile, MySQL restricts the packet size that the server accepts.
Sometimes large inserts and updates are limited by max_allowed_packet parameters, resulting in failure.
View current configuration
Show VARIABLES like '%max_allowed_packet% ';
The results displayed are:
+--------------------+---------+
| variable_name | Value |
+--------------------+---------+
| Max_allowed_packet | 1048576 |
+--------------------+---------+
The above description is currently configured as: 1M
Modify method
1) Method 1
You can edit the my.cnf to modify (Windows My.ini), either in the [Mysqld] section or in the MySQL server configuration section.
Max_allowed_packet = 20M
If you can't find my.cnf, you can pass the
MySQL--help | grep my.cnf
To find my.cnf files.
2) Method 2
(very compromise, very tangled approach)
Access to MySQL server
Running on the MySQL command line
Set Global Max_allowed_packet = 2*1024*1024*10
Then shut down this MySQL server link and re-enter.
Show VARIABLES like '%max_allowed_packet% ';
See if Max_allowed_packet edits successfully