Duplicate entry for key primary after Update to Matomo 4

Hi @Lukas,

just updated from Matomo 3.4.1 to Matomo 4.0.1. Another update scenario was not given.

First of all, the update stuck because of an error saying something like
“mysqli statement execute error : duplicate entry” for key ‘primary’

I could solve this by going through the troubleshooting steps given in the updater: Increase the max_execution_size and memory_limit, followed by updating the “version_core” value to version “4.0.1” because still “3.4.1” was there.

Update was successful. But: When I try to login, all that happens is a “refresh” of the login page. I’m not sure if the login attempt is succeeded, I only see the login page.

Holy cow, I will now start my research through the forum. Let’s see what happens.



Please don’t manually update the version in the database as this way you skip applying all database changes that are needed for the update.

If the duplicate entry was in the session table, please take a look here:

1 Like

This seems a lot like this issue:

Could you try deleting/truncating everything in the matomo_session table (this should just log everyone out) and then reverting the version in the database and running the update?

1 Like

Hi Lukas,

Well, this was told by the update page from the Matomo page itself. I just did what was mentioned.

But nevertheless, this was the solution:

Thank you very much. I am now able to login again.


1 Like

You are right, I’ll look into maybe removing that suggestion as it is not ideal.

Great to hear that this worked for you.

1 Like

Yeah, this would be great. :point_up: