Search code examples
phpmysqlmatomo

Piwik upgrading to MySQL 5.7+ SQLSTATE[HY000]: General error: 2006 MySQL server has gone away - caused by plugin Actions


Upgrading MySQL to 5.7 on a previous working Piwik has broken it. Most of the dashboard widgets now error with:

Referrer Websites SQLSTATE[HY000]: General error: 2006 MySQL server has gone away - caused by plugin Actions Widget Overview SQLSTATE[HY000]: General error: 2006 MySQL server has gone away - caused by plugin Actions

As per the FAQ I have increased the following parameters:

wait_timeout=100000
max_allowed_packet=128M

Restarted and so on. Even tried re importing the database and removing the character sets as per another solution. Thanks for help.


Solution

  • This was resolved in my original github post https://github.com/piwik/piwik/issues/9419. I'm posting the answer here to help others: The solution ended up being an issue with the character sets and an issue with the file upload scripts.

    1. MySQL 5.7.5+ has now become strict on this setting. By default this is a programdata windows directory but piwik requires the following (depending on your environment):

      secure-file-priv="xxxxxxxxxxxxx/piwik/tmp/assets"

    If this is not set - the real error is:

    General error: 1290 The MySQL server is running with the --secure-file-priv option so it cannot execute this statement: LOAD DATA INFILE xxxxxxxxxxxx

    But of course all we can see is the 2006 gone away error......

    1. MySQL > 5.7+ now installs by default a utf8 character set - it appears that piwik has some problems with this according to the trace I eventually got -(yes the invalid character is really an '"x'?):

    SQLSTATE[HY000]: General error: 1300 Invalid utf8 character string: '"x':

    In Mysql I was able to change the default "schema" piwik database to "latin1" and like magic everything worked again. This leads me to assume that converting a latin1 db over to utf8 might encounter similar issues as I did. I know character sets are a mine field but I wouldn't expect to see issues going from a latin1 to utf8 dataset (as they in theory should be a subset but hey this is still possible) - the other way around yes of course there should be issues most certainly.