Skip to content

Check mysql database charset when installation #25411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ err_empty_admin_email = The administrator email cannot be empty.
err_admin_name_is_reserved = Administrator Username is invalid, username is reserved
err_admin_name_pattern_not_allowed = Administrator username is invalid, the username matches a reserved pattern
err_admin_name_is_invalid = Administrator Username is invalid
err_mysql_charset_must_utf8mb4 = The MySQL database should use UTF8Mb4 only

general_title = General Settings
app_name = Site Title
Expand Down
6 changes: 6 additions & 0 deletions routers/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool {
return false
}

if setting.Database.Type == "mysql" && setting.Database.Charset != "utf8mb4" {
ctx.Data["Err_DbCharset"] = true
ctx.RenderWithErr(ctx.Tr("install.err_mysql_charset_must_utf8mb4"), tplInstall, form)
return false
}

// Check if the user is trying to re-install in an installed database
db.UnsetDefaultEngine()
defer db.UnsetDefaultEngine()
Expand Down
2 changes: 1 addition & 1 deletion templates/install.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</div>

<div class="gt-hidden" data-db-setting-for="mysql">
<div class="inline required field">
<div class="inline required field {{if .Err_DbCharset}}error{{end}}">
<label>{{.locale.Tr "install.charset"}}</label>
<div class="ui selection database type dropdown">
<input type="hidden" name="charset" value="{{if .charset}}{{.charset}}{{else}}utf8mb4{{end}}">
Expand Down