SQLSTATE[HY000] [1040] Too many connections category - Matomo 3.14

After upgrading to Matomo 3.14 I am facing several issues:

When upgrading, I ran into an error saying the following:

Entry “DeviceDetector\Cache\Cache” cannot be resolved: the class is not instantiable. Full definition: Object ( class = #NOT INSTANTIABLE# DeviceDetector\Cache\Cache scope = singleton lazy = false )<<

I was searching for solution. They were:

  • update DOMAIN/matomo/config/global.php manually
  • rename DOMAIN/matomo/config/config.ini.php

This did not solve the issue, and so I reinstalled Matomo from scratch. This seemed to work. But now I found the error when I refresh my Matomo page: “SQLSTATE[HY000] [1040] Too many connections category”

I’ve had a look into this discussion: :(Upgrading from 1.6 to 1.7 after Too many connections - Yes, this is old and has nothing to do with Matomo 3.14. The solution was a patch. What may be the solution for the new occurance?

Strange behavior, because the error does not occur always. And sometimes I receive a red message in Matomo Dashboard, saying “Oooops, something went wrong, please contact your Matomo administrator” or similar.

I was always satisfied with Matomo. It always gave me a good overview and the possibility of deeper analysis. But the UX decreased with Matomo 3.14. :frowning:

Thanks and have a nice day.

Henning

Hi,

I hope by this you don’t mean you deleted the database, but just ran the installer again connecting to the existing database tables as otherwise you would have lost a lot of data for a simple fix.

The error message comes from MySQL itself, so this has to do with the PHP<->Mysql connection.

Many people report that different things helped them:

Try using mysqli instead of PDO for the connection in Matomo (or the other way round). (you can change the adapter either during the initial setup or in the config/config.ini.php)

Or you could try one of the nd_mysqli php modules which seem to work better for some people.

1 Like

Hi Lukas,

ich habe gesehen, dass du Deutsch verstehst, also würde ich gern in Deutsch weitermachen.

Also: Nein, ich habe die bisherige Datenbank wieder verbunden. Sorry, das hätte ich vielleicht erwähnen sollen. https://www.henning-uhle.eu/informatik/wordpress-und-bloggen/matomo-devicedetectorcachecache-cannot-be-enabled

In dem verlinkten Thread in deiner Antwort ist ein weiterer Thread verlinkt (Problems with PHP 7.2). Dort habe ich gelesen, dass man schauen soll, ob MYSQLI erwähnt wird. Das ist bei mir nicht der Fall. Ach ja, der Daniel im Thread hatte Fehler im Error Log. Das ist allerdings bei mir komplett leer.

Ich stelle mich da etwas doof an. Wie müsste ich denn ein “nd_mysqli” PHP-Modul einbauen?

Edith merkt an: In den Matomo-Einstellungen ist wohl beides (PDO und MYSQLI) aktiv:

Grüße
Henning

Hallo,
Die nd_mysqli Unterscheidung gibt es glaube ich nur bei manchen Hostern (PHP Version change causes "server gone away" error)

Du könntest probieren, die config.ini.php zu bearbeiten und in der [database] section adapter = "MYSQLI" einfügen. Vielleicht war das vor dem Neuinstallieren gesetzt und funktioniert in Kombination mit deinem Serverhost (bzw. dessen anscheinend niedrigen Beschränkungen) besser.

1 Like

Hi Lukas,

das ist eben die große Preisfrage. Das lässt sich ja nicht mehr nachvollziehen. Manuell gesetzt hatte ich da jedenfalls nichts. Du meinst also genau so:

matomodb

Dann würde ich die bearbeitete config.ini.php hochladen und dann mal schauen, was passiert.

1 Like

Hi Lukas,

Ich glaube, ich kann das Thema als gelöst betrachten. Die Anpassung hat wohl was gebracht. Vielen Dank.

Grüße
Henning

1 Like

It could help to others in the forum if you were willing to use English as “vehicular language”

1 Like

Hi @prdv,

Personally I agree and I wouldn’t mind if every post on this forum was made in English. (As I would not have to repeat myself as often). But as Matomo is used by a lot of people who don’t know English or (more likely) don’t feel too comfortable with their proficiency, also helping people in German means that more people can enjoy using Matomo.

So as this is a post that will probably be found by quite a few users, a quick English summary:

Those SQLSTATE errors come directly from MySQL and depend a lot on how your setup between MySQL and PHP works. In this case it seems like the shared host is limiting the simulaneous connections quite strongly, but switching the default MySQL adapter from PDO to MYSQLI (which normally doesn’t work as well for some users) did the trick here to make everything work again.

1 Like

Hi @prdv, I must admit that I was too lazy to think in English. But I have no problems in using English. Luckily @Lukas summarized the solution.

2 Likes

Thank you, @Lukas for translating and summarizing.