Can't install Mail app

Hi,

I couldn’t upgrade the Mail app to 3.4.0.
I deleted it, removed all rows on oc_migrations where app= ‘mail’, removed all ‘oc_mail/*’ tables.
At first, when I click on “Download and enable”, it creates all the tables, but it fails with this error:

But then it says “Enable” on the button, so I click on it, and it fails because the tables already exist.

I get no log message whatsoever when installing for the first time, so I don’t know why it fails. I know why it fails on the second attempt, since the tables exist, but why it fails on the first attempt is a mystery to me.

I even tried to, after deleting everything, to download it manually to see if it makes a difference.

It doesn’t seem so, except that I get this error:

Database error when running migration 1120Date20220223094709 for app mail An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1142 REFERENCES command denied to user ‘nextcloud’@‘localhost’ for table ‘nextcloud.oc_mail_local_messages’.

I have no idea what is causing this.

Can anyone help me?
Best,
Francis

Have you tried to run the following steps to cleanup the installation?

Yes, I tried this all, except oc_appconfig. I just did it again, but now I get this:

An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1142 REFERENCES command denied to user 'nextcloud'@'localhost' for table 'nextcloud.oc_mail_local_messages'

Any clue on what this could be?