报错日志:
### The error may exist in io/base/modules/enterpriseInfo/dao/EnterpriseInfoDao.java (best guess) ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT id AS id,is_del AS isDel,`name`,appid,credit_code AS creditCode,register_address AS registerAddress,communication_address AS communicationAddress,found_date AS foundDate,legal_person AS legalPerson,legal_person_phone AS legalPersonPhone,principal,principal_we_chat AS principalWeChat,principal_phone AS principalPhone,email,`scale`,supervision_industry AS supervisionIndustry,economy_type AS economyType,business_scope AS businessScope,registered_capital AS registeredCapital,employee_num AS employeeNum,total_assets AS totalAssets,fixed_assets AS fixedAssets,remark,create_time AS createTime,create_name AS createName,last_update_time AS lastUpdateTime,last_update_name AS lastUpdateName,fax,postal_code AS postalCode,subjection,main_income AS mainIncome,annual_income AS annualIncome,annual_profit AS annualProfit,abbreviation,longitude,dimension,product,introduce,group_flag AS groupFlag,group_company AS groupCompany,parent_company_name AS parentCompanyName,parent_company_code AS parentCompanyCode,divisions_one AS divisionsOne,divisions_two AS divisionsTwo,supervision_industry_two AS supervisionIndustryTwo,economy_type_two AS economyTypeTwo,national_type_one AS nationalTypeOne,national_type_two AS nationalTypeTwo,national_type_three AS nationalTypeThree,national_type_four AS nationalTypeFour,subordinate FROM qy_enterprise_info WHERE id=? AND is_del=0 ### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1375 > 1024). You can change this value on the server by setting the max_allowed_packet' variable. ; ]; Packet for query is too large (1375 > 1024). 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 (1375 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
今天像往常一样启动项目。访问,进首页,然后。。。。报错了!看了下报错日志就是上边这段。
大致意思是:查询的数据大于mysql设置返回数据的最大值,让去改max_allowed_packet参数,有两种办法解决该问题
方法一(临时解决,最快速,一条SQL即可解决):
用SQL语句的方法解决,可以先查询一下当前max_allowed_packet的大小
SHOW VARIABLES LIKE '%max_allowed_packet%';
然后执行:
SET GLOBAL max_allowed_packet = 10 * 1024 * 1024;
执行完SQL后重启下自己项目后问题就解决不了,但是这个方法治标不治本,遇到数据库重启后max_allowed_packet还会恢复到之前的1024,开发遇到此问题可临时解决下,忙完手头的事情可使用第二种方法彻底解决。
方法二(修改数据库配置文件):
找到数据库的安装目录,这里以windows为例,找到数据库的配置文件
找到配置文件后,编辑下他,把max_allowed_packet解开注释,或者添加上去,如下图
附上我的配置文件内容
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES max_allowed_packet = 32M
修改完配置文件后,重启下Mysql的服务即可根治
文章来源:
不凡
版权声明:本站所发布的全部内容源于互联网搬运,仅供用于学习和交流,如果有侵权之处请第一时间联系我们删除。敬请谅解! E-mail:xujinxiao@126.com
还木有评论哦,快来抢沙发吧~