当前位置:网站首页>MySQL exception: com mysql. jdbc. PacketTooBigException: Packet for query is too large(4223215 > 4194304)

MySQL exception: com mysql. jdbc. PacketTooBigException: Packet for query is too large(4223215 > 4194304)

2022-06-13 00:54:00 zly3500

as a result of MySQL Of max_allowed_packet The setting is too small ,max_allowed_packet If not set , The default values are in different MySQL Different versions , Some versions default to 1M, Some versions default to 4M.

mysql According to the configuration file, it will limit server Accepted packet size . Sometimes big inserts and updates are max_allowed_packet Parameters limit , Result in failure .

1、 View the current configuration :

Get into MYSQL

command : mysql -uroot -p
Enter password:mysql password  

( Or other database connection tools , Query or command-line interface can also )

View the current configuration :
Input show variables like '%max_allowed_packet%';

mysql>  show variables like '%max_allowed_pack%';

 2、1 Modify the configuration , What I set up here is 20M

stay MYSQL Internal input set global max_allowed_packet = 2*1024*1024*10;(20M)

mysql> set global max_allowed_packet = 10 * 1024 * 1024;

2、2( Profile persistent modification ):
vim /etc/my.cnf
[mysqld]
max_allowed_packet = 100M

Be careful : After modifying the configuration file , Need to restart mysql Service to take effect

1、 Use service start-up :service mysqld restart

2、 Use mysqld The script to start :/etc/inint.d/mysqld restart


start-up :# service mysqld start
stop it :# service mysqld stop
restart :# service mysqld restart

原网站

版权声明
本文为[zly3500]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130049345548.html