Failed upgrade 1.19-1.20.1: database collation

Hi,

My migration from 1.19 to 1.20.1 has failed because of Mysql database collation. All my tables have been using utf8mb4_general_ci for ages, which looks correct according to Gitea’s doc ( Database Preparation | Gitea Documentation ): " Create database with UTF-8 charset and collation. Make sure to use utf8mb4 charset […] When in doubt, use either unicode_ci or general_ci."

Yet, when starting Gitea 1.20.1, I now have:

.../setting/database.go:75:loadDBSetting() [E] Deprecated database mysql charset utf8 support, please use utf8mb4 and convert utf8 database to utf8mb4 by "gitea convert".
[...]
routers/common/db.go:34:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: Error 1115 (42000): Unknown character set: 'utf8mb4_general_ci

If I launch gitea convert with v1.19, it does nothing. If I do it with 1.20.1, it fails with the same error.

Should I convert my database and, if so, how? Help would be appreciated!

The first error is caused by having [DATABASE] CHARSET set to something other than utf8mb4 in app.ini. You can safely remove this in 1.20.x, as it now defaults to utf8mb4 (see: Use "utf8mb4" for MySQL by default by wxiaoguang · Pull Request #25432 · go-gitea/gitea · GitHub).

I believe the second error is because you incorrectly set CHARSET to utf8mb4_general_ci. That value is NOT a charset, that value is a collation. The charset for that collation would be utf8mb4. Same solution: remove that configuration line from the database config, or set it to utf8mb4.

1 Like

Hi @jake ,
That was it: the CHARSET was indeed in my app.ini. Removing it solved the issue.

Thank you for the help!

2 Likes