diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-01-10 19:03:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-10 11:03:23 +0000 |
commit | 2df7563f3176aa8c7dcb070f660d53da4bb66e78 (patch) | |
tree | acf64c3f4d40f15e0fc28d4f6060644172cc46f0 /docs/content/installation | |
parent | a80debc208fbf0ecf6ca734e454cae08adafb570 (diff) | |
download | gitea-2df7563f3176aa8c7dcb070f660d53da4bb66e78.tar.gz gitea-2df7563f3176aa8c7dcb070f660d53da4bb66e78.zip |
Recommend/convert to use case-sensitive collation for MySQL/MSSQL (#28662)
Mainly for MySQL/MSSQL.
It is important for Gitea to use case-sensitive database charset
collation. If the database is using a case-insensitive collation, Gitea
will show startup error/warning messages, and show the errors/warnings
on the admin panel's Self-Check page.
Make `gitea doctor convert` work for MySQL to convert the collations of
database & tables & columns.
* Fix #28131
## :warning: BREAKING :warning:
It is not quite breaking, but it's highly recommended to convert the
database&table&column to a consistent and case-sensitive collation.
Diffstat (limited to 'docs/content/installation')
-rw-r--r-- | docs/content/installation/database-preparation.en-us.md | 8 | ||||
-rw-r--r-- | docs/content/installation/database-preparation.zh-cn.md | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/docs/content/installation/database-preparation.en-us.md b/docs/content/installation/database-preparation.en-us.md index 5e0b94665f..e6abb8a613 100644 --- a/docs/content/installation/database-preparation.en-us.md +++ b/docs/content/installation/database-preparation.en-us.md @@ -61,10 +61,14 @@ Note: All steps below requires that the database engine of your choice is instal Replace username and password above as appropriate. -4. Create database with UTF-8 charset and collation. Make sure to use `utf8mb4` charset instead of `utf8` as the former supports all Unicode characters (including emojis) beyond _Basic Multilingual Plane_. Also, collation chosen depending on your expected content. When in doubt, use either `unicode_ci` or `general_ci`. +4. Create database with UTF-8 charset and case-sensitive collation. + + `utf8mb4_bin` is a common collation for both MySQL/MariaDB. + When Gitea starts, it will try to find a better collation (`utf8mb4_0900_as_cs` or `uca1400_as_cs`) and alter the database if it is possible. + If you would like to use other collation, you can set `[database].CHARSET_COLLATION` in the `app.ini` file. ```sql - CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'; + CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin'; ``` Replace database name as appropriate. diff --git a/docs/content/installation/database-preparation.zh-cn.md b/docs/content/installation/database-preparation.zh-cn.md index b58344133e..d651088395 100644 --- a/docs/content/installation/database-preparation.zh-cn.md +++ b/docs/content/installation/database-preparation.zh-cn.md @@ -59,10 +59,12 @@ menu: 根据需要替换上述用户名和密码。 -4. 使用 UTF-8 字符集和排序规则创建数据库。确保使用 `**utf8mb4**` 字符集,而不是 `utf8`,因为前者支持 _Basic Multilingual Plane_ 之外的所有 Unicode 字符(包括表情符号)。排序规则根据您预期的内容选择。如果不确定,可以使用 `unicode_ci` 或 `general_ci`。 +4. 使用 UTF-8 字符集和大小写敏感的排序规则创建数据库。 + + Gitea 启动后会尝试把数据库修改为更合适的字符集,如果你想指定自己的字符集规则,可以在 app.ini 中设置 `[database].CHARSET_COLLATION`。 ```sql - CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci'; + CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin'; ``` 根据需要替换数据库名称。 |