10

When I try and run a sonar analysis I get this exception

com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1807198 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.

Where on the sonar server should I set this value?

I'm using Sonar 3.4.1 and MySQL 5.x

Ben
  • 51,770
  • 36
  • 127
  • 149
satish marathe
  • 1,073
  • 5
  • 18
  • 37

2 Answers2

20

Locate the config file my.cnf (If your MySQL is running in Windows, locate my.ini)

Add this to the config file

[mysqld]
max_allowed_packet=256M

Then, restart mysql

  • For Linux, service mysql restart
  • For Windows
    • net stop mysql
    • net start mysql

Give it a Try !!!

RolandoMySQLDBA
  • 43,883
  • 16
  • 91
  • 132
  • Thanks for this. Mine was located in /etc/my.cnf. Information is here http://serverfault.com/questions/346647/mysql-wheres-the-my-cnf-path and the magic command to find where it might be is `mysql --help | grep "Default options" -A 1` – Ashley Frieze Oct 20 '16 at 12:28
  • 5
    I needed to restart my sonar server for this to eventually work `sudo service sonar restart` – Ashley Frieze Oct 20 '16 at 14:06
  • Restarting the sonar server along with the solution worked for me. Thanks for the tip @AshleyFrieze – Udara Jayawardana Aug 17 '18 at 10:23
6

I had a same issue however, we had a limitation where we could not change the MySQL server configuration (max_allowed_packet)

I was able to get this working by changing the Client side jdbc URL configurations -> leaving the server config as is.

jdbc:mysql://[dbhost]:[dbport]?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf8&useServerPrepStmts=true&maxAllowedPacket=20000000&useSSL=false

Check the mysql connector config reference here

There is one more post on SO that talks abt Client side change in detail - check here

Hope this helps!

Rishi
  • 5,869
  • 7
  • 34
  • 45