0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2024-11-24 18:09:26 -05:00

admin: database: Suggest a better collation for MySQL

In `admin/database-preparation` suggest `utf8mb4_bin` as the collate
function, rather than `utf8mb4_unicode_ci`. The former is accent- and
case sensitive, while the latter isn't, and Forgejo assumes that columns
are case sensitive.

Also add a short paragraph explaining why `utf8mb4_bin` is
suggested (case sensitivity), and what problems may arise and why if
case insensitive collation is used.

This partially addresses forgejo/forgejo#2039.

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2023-12-28 11:46:34 +01:00
parent cc4162ecb8
commit 5958b3a618
No known key found for this signature in database

View file

@ -46,14 +46,16 @@ 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 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, but make sure that the collation is accent- and case sensitive. When in doubt, use `utf8mb4_bin`.
```sql
CREATE DATABASE forgejodb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
CREATE DATABASE forgejodb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
```
Replace database name as appropriate.
Using an accent- and case sensitive collation such as `utf8mb4_bin` is important, because Forgejo often relies on these sensitivities, and if those assumptions are broken, that may lead to internal server errors or other unexpected results.
5. Grant all privileges on the database to database user created above.
For local database: