用Mysql数据库保存Blob类型的数据时,抛出异常:Packet for query is too large (1091664 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.; nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1091664 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
原因:Mysql默认配置为存储1M大小的文件,当文件超出大小时,会抛出此异常。
解决方法:修改Mysql的配置。
使用命令:SHOW GLOBAL VARIABLES LIKE '%max_allowed_packet%' 查看max_allowed_packet的大小
SET GLOBAL max_allowed_packet = #size 修改为你想要的大小