sonar扫描时报Failed to upload report - An error has occurred. Please contact your administrator

本人新学习使用此软件,参考网络各大神资料后解决问题方法如下:
此问题产生的原因在于mysql的max_allowed_packet 参数限制默认为4M。将设置进行修改就可以了。
mysql根据配置文件会限制server接受的数据包大小。

有时候大的插入和更新会受max_allowed_packet 参数限制,导致写入或者更新失败。

查看目前配置

show VARIABLES like ‘%max_allowed_packet%’;

显示的结果为:

±-------------------±--------+

| Variable_name | Value |

±-------------------±--------+

| max_allowed_packet | 1048576 |

±-------------------±--------+

以上说明目前的配置是:1M

修改方法

1、修改配置文件

可以编辑my.cnf来修改(windows下my.ini),在[mysqld]段或者mysql的server配置段进行修改。

max_allowed_packet = 20M
如果找不到my.cnf可以通过

mysql --help | grep my.cnf
去寻找my.cnf文件。

linux下该文件在/etc/下。
Windows系统下查找此文件
1).进入管理
sonar扫描时报Failed to upload report - An error has occurred. Please contact your administrator
2).找到mysql服务(笔者用的是mysql5.7),右键点击属性
sonar扫描时报Failed to upload report - An error has occurred. Please contact your administrator
sonar扫描时报Failed to upload report - An error has occurred. Please contact your administrator
3).拷贝可执行文件的路径,“C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe” --defaults-file=“C:\ProgramData\MySQL\MySQL Server 5.7\my.ini” MySQL57,找到C:\ProgramData\MySQL\MySQL Server 5.7路径下的my.ini文件进行修改
sonar扫描时报Failed to upload report - An error has occurred. Please contact your administrator
4).重启数据库服务,重启sonar进行扫描。再进行扫描,问题解决。

2、在mysql命令行中修改(此方法不推荐使用,重启后失效)

在mysql 命令行中运行

set global max_allowed_packet = 210241024*10
然后退出命令行,重启mysql服务,再进入。

show VARIABLES like ‘%max_allowed_packet%’;
查看下max_allowed_packet是否编辑成功