According to the configuration file, MySQL limits the size of the data packets accepted by the Server. Sometimes large inserts and updates are limited by the max_allowed_packet parameter, causing write or update failures. (For example, import database, data table)
The following errors appear in the process of migrating or restoring the mysql database:
ERROR 1231 ( 42000 ): Variable ' time_zone ' can ' t be set to the value of ' NULL ' ERROR 1231 (42000): Variable ' sql_mode ' can ' t be set to the value of ' NULL ' ERROR 1231 ( 42000 ): Variable ' foreign_key_checks ' can ' t be set to the value of ' NULL ' ERROR 1231 (42000): Variable 'unique_checks ' can ' t be set to the value of ' NULL ' ERROR 1231 ( 42000 ): Variable ' character_set_client ' can ' t be set to the value of ' NULL ' Query OK, 0 rows affected (0.00 sec) ERROR 1231 (42000): Variable ' collation_connection ' can ' t be set to the value of ' NULL ' ERROR 1231 ( 42000 ): Variable ' sql_notes ' can ' t be set to the value of ' NULL '
Solution:
Modify the mysql configuration file: max_allowed_packet=1024M
View the current configuration:
show VARIABLES like ' %max_allowed_packet% ' ;
The results displayed are:
| Variable_name | Value |
+———— ——–+———+
| max_allowed_packet | 1048576 |
+——————–+—- —–+
The above description shows that the current configuration is: 1M
Modification method
1. Modify the configuration file
You can edit my.cnf to modify (my.ini under windows), and modify it in the [mysqld] section or the mysql server configuration section.
If you can’t find my.cnf, you can pass
Look for the my.cnf file.
The file is under /etc/ under linux.
Restart mysql:
1. Start with service: service mysqld restart
2. Start with mysqld script: /etc/inint.d/mysqld restart
Check whether max_allowed_packet is successfully edited
Note: Setting this value too small will cause a single record to fail to write to the database after exceeding the limit, and subsequent record writing will also fail.
Read More:
- Mybatis Error: The server time zone value ‘����1532a0’ is unrecognized
- [Solved] tidb-cdc Create Task Error: Unknown or incorrect time zone
- PLSQL environment variable configuration tnsnames.ora file path
- [Solved]ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql
- Lock request time out period exceeded. (Microsoft SQL Server, Error: 1222)
- How to Solve mysql [Err] 1067-Invalid default value for
- How to Solve mysqld — console command error
- How to Solve MYSQL into outfile Error13
- How to Solve MYSQL Error: Failed to start MySQL 8.0 database server
- How to Solve Mysql8 load data error
- How to Solve MySQL version 5.7+ Group by group error
- How to Solve Nacos startup error
- How to Solve Azkaban startup error
- How to Solve “Out of range value for column” Error
- Docker: How to Solve MYSQL8 & Navicat remote connection error
- How to Solve c3p0 connect mysql8.0 Error
- How to Solve SQL state [HY000]: general error 2503
- How to Solve Error: Rsa Public Key not Find
- How to Solve MYSQL Error: No module named MySQLdb
- How to Solve MYSQL ERROR: relation “table_name” does not exist