Error after changing the database character set to utf8mb4

I saw this message in the System Check option:
“Your database supports utf8mb4 charset, but your database tables have not been converted yet. You can do this by executing the command console core:convert-to-utf8mb4”

So, I ran that command, and it succeeded without any issues or warnings. However, after that I could no longer access my Matomo admin page. It gave this error:

Could not connect to the database:

SQLSTATE[42000] [1253] COLLATION ‘utf8mb3_general_ci’ is not valid for CHARACTER SET ‘utf8mb4’

I have tried manually changing all the collation to utf8mb4_general_ci in phpMyadmin. Exported and checked that there’s nothing in the database that referenced utf8mb3. I also tried changing everything back to utf8mb3 and utf8mb3_general_ci. Nothing worked. It still gives the same error.

I’m using these versions:
Matomo version: 5.1.2
MySQL version: 10.6.20-MariaDB-cll-lve-log
PHP version: 8.3.13

check this buddy, end of the thread it’s a potential solution:

Thanks. I tried and that also didn’t help. My MySQL supports utf8mb4 for sure because I can see some tables created long ago with utf8mb4 and they have been running fine.

I found where the problem was. It wasn’t the database. In config/config.ini.php, collation was set incorrectly as
charset = “utf8mb4”
collation = “utf8mb3_general_ci”

The page was working again after I changed it to
charset = “utf8mb4”
collation = “utf8mb4_unicode_ci”