I’m trying to migrate Matomo to a new server but I have an issue with the db. Matomo on new host complains about that:
## **SQLSTATE[HY000] [2019] Unknown character set**
I have tried using PHPMyAdim to change the character set of tables and columns and updating config file in same time but it still keeps giving that error message. I have tried utf8_unicode_ci, utf8_general_ci and same with utf8mb4 but still same error
New server is running MariaDB 10.4 and PHP 8.2
MariaDB is working perfectly fine (it’s on a shared hosting server).
I found the solution by using differenc character set for data and collations:
charset = "utf8"
collation = "utf8_unicode_ci"
Edit: it worked few minutes and now it makes a new error, just a nightmare to fix that thing ## **SQLSTATE[42000] [1253] COLLATION 'utf8_unicode_ci' is not valid for CHARACTER SET 'utf8mb4'**
I think your issue might be with the Shared Hosting.
The collation utf8_unicode_ci is valid only for the utf8 character set, not for utf8mb4, which is often the default in modern MariaDB/MySQL installations.
On shared hosting servers you may not have access to the configuration files (i.e.my.cnf) to globally set the character set and collation. Instead, you’ll need to explicitly set the character set and collation in your database, tables, or connection code.
I’d reach out to the hosting support regarding this.
I’ve never seen this error and I use only private VPSs, my own ones or for clients.
PS: What you can do to check what I said above is to run the following SQL query to check the server defaults:
SHOW VARIABLES LIKE 'character_set%';
SHOW VARIABLES LIKE 'collation%';
This will show the default character set and collation for the server. If the default is utf8mb4, you’ll need to adjust your configuration to match.
PPS: I’ve found myself personally tweaking things with MariaDB and getting it to work smoother with lots of back and forth terminal commands, taking notes etc. I suggest you try, reach out to support and let us know how you go.
@metrprime sorry for late answer. Regarding the shared hosting, I have no problem to setup an instance on it with Matomo installed from their control panel.
I can modify charset and collation of all Matomo tables/db through PHPMyAdmin but I can’t find a combination working (modifying in same time matomo config file of course).
I thought to use utf8_unicode_ci for everything but then Matomo tells it’s an unknown character set What do you use as default encoding for both tables and collations ?
here are results of the shared hosting server but which couple should I use that will work with Matomo ?