Chinese language cause error

Viewed 150

Even administrator users cannot delete questions, modify questions, or modify any system settings.

This is true even if the answer system is reinstalled after deleting the database.

image.png

image.png

image.png

I feel like there will be problems as long as you use Chinese. For example, adding a Chinese tag will automatically jump to this page:

image.png
image.png

The log:

[i18n] install sv_SE.yaml file exist, try to replace it
[i18n] install sv_SE.yaml bundle...
[i18n] install sv_SE.yaml bundle success
[i18n] install tr_TR.yaml file exist, try to replace it
[i18n] install tr_TR.yaml bundle...
[i18n] install tr_TR.yaml bundle success
[i18n] install uk_UA.yaml file exist, try to replace it
[i18n] install uk_UA.yaml bundle...
[i18n] install uk_UA.yaml bundle success
[i18n] install vi_VN.yaml file exist, try to replace it
[i18n] install vi_VN.yaml bundle...
[i18n] install vi_VN.yaml bundle success
[i18n] install zh_CN.yaml file exist, try to replace it
[i18n] install zh_CN.yaml bundle...
[i18n] install zh_CN.yaml bundle success
[i18n] install zh_TW.yaml file exist, try to replace it
[i18n] install zh_TW.yaml bundle...
[i18n] install zh_TW.yaml bundle success
try to create cache directory /data/cache
try to load cache file from /data/cache/cache.db
open /data/cache/cache.db: no such file or directory
try to save cache file to /data/cache/cache.db

upgrade done
config file path:  /data/conf/config.yaml
Answer is string..........................
2023-09-14 17:01:12.594	INFO	data/data.go:99	try to load cache file from /data/cache/cache.db
start cron
answer Version: 1.1.3  Revision: fd36ef4
sitemap cron execution
sitemap cron execution
sitemap cron execution
sitemap cron execution
sitemap cron execution
sitemap cron execution
sitemap cron execution
sitemap cron execution
[mysql] 2023/09/15 01:58:21 packets.go:123: closing bad idle connection: EOF
[mysql] 2023/09/15 01:58:21 connection.go:173: driver: bad connection
sitemap cron execution
2023-09-15 02:02:54.247	ERROR	handler/handler.go:34	code: 500, reason: base.database_error, message: , error: Error 1267: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/repo/tag_common/tag_common_repo.go:83 github.com/answerdev/answer/internal/repo/tag_common.(*tagCommonRepo).GetTagListByName
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/service/tag_common/tag_common.go:89 github.com/answerdev/answer/internal/service/tag_common.(*TagCommonService).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/controller/tag_controller.go:48 github.com/answerdev/answer/internal/controller.(*TagController).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/base/middleware/auth.go:116 github.com/answerdev/answer/internal/base/middleware.(*AuthUserMiddleware).MustAuth.func1
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:620 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:576 github.com/gin-gonic/gin.(*Engine).ServeHTTP
/usr/local/go/src/net/http/server.go:2947 net/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:1991 net/http.(*conn).serve
/usr/local/go/src/runtime/asm_amd64.s:1594 runtime.goexit
2023-09-15 02:03:20.214	ERROR	handler/handler.go:34	code: 500, reason: base.database_error, message: , error: Error 1267: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/repo/tag_common/tag_common_repo.go:83 github.com/answerdev/answer/internal/repo/tag_common.(*tagCommonRepo).GetTagListByName
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/service/tag_common/tag_common.go:89 github.com/answerdev/answer/internal/service/tag_common.(*TagCommonService).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/controller/tag_controller.go:48 github.com/answerdev/answer/internal/controller.(*TagController).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/base/middleware/auth.go:116 github.com/answerdev/answer/internal/base/middleware.(*AuthUserMiddleware).MustAuth.func1
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:620 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:576 github.com/gin-gonic/gin.(*Engine).ServeHTTP
/usr/local/go/src/net/http/server.go:2947 net/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:1991 net/http.(*conn).serve
/usr/local/go/src/runtime/asm_amd64.s:1594 runtime.goexit
2023-09-15 02:03:49.148	ERROR	handler/handler.go:34	code: 500, reason: base.database_error, message: , error: Error 1267: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/repo/tag_common/tag_common_repo.go:83 github.com/answerdev/answer/internal/repo/tag_common.(*tagCommonRepo).GetTagListByName
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/service/tag_common/tag_common.go:89 github.com/answerdev/answer/internal/service/tag_common.(*TagCommonService).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/controller/tag_controller.go:48 github.com/answerdev/answer/internal/controller.(*TagController).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/base/middleware/auth.go:116 github.com/answerdev/answer/internal/base/middleware.(*AuthUserMiddleware).MustAuth.func1
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:620 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:576 github.com/gin-gonic/gin.(*Engine).ServeHTTP
/usr/local/go/src/net/http/server.go:2947 net/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:1991 net/http.(*conn).serve
/usr/local/go/src/runtime/asm_amd64.s:1594 runtime.goexit
2023-09-15 02:03:58.309	ERROR	handler/handler.go:34	code: 500, reason: base.database_error, message: , error: Error 1267: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/repo/tag_common/tag_common_repo.go:83 github.com/answerdev/answer/internal/repo/tag_common.(*tagCommonRepo).GetTagListByName
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/service/tag_common/tag_common.go:89 github.com/answerdev/answer/internal/service/tag_common.(*TagCommonService).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/controller/tag_controller.go:48 github.com/answerdev/answer/internal/controller.(*TagController).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/base/middleware/auth.go:116 github.com/answerdev/answer/internal/base/middleware.(*AuthUserMiddleware).MustAuth.func1
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:620 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:576 github.com/gin-gonic/gin.(*Engine).ServeHTTP
/usr/local/go/src/net/http/server.go:2947 net/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:1991 net/http.(*conn).serve
/usr/local/go/src/runtime/asm_amd64.s:1594 runtime.goexit
2023-09-15 02:05:11.649	ERROR	handler/handler.go:34	code: 500, reason: base.database_error, message: , error: Error 1267: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/repo/tag_common/tag_common_repo.go:83 github.com/answerdev/answer/internal/repo/tag_common.(*tagCommonRepo).GetTagListByName
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/service/tag_common/tag_common.go:89 github.com/answerdev/answer/internal/service/tag_common.(*TagCommonService).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/controller/tag_controller.go:48 github.com/answerdev/answer/internal/controller.(*TagController).SearchTagLike
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/answerdev/answer/internal/base/middleware/auth.go:116 github.com/answerdev/answer/internal/base/middleware.(*AuthUserMiddleware).MustAuth.func1
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/context.go:174 github.com/gin-gonic/gin.(*Context).Next
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:620 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
/go/src/github.com/answerdev/answer/answer_build2703776218/vendor/github.com/gin-gonic/gin/gin.go:576 github.com/gin-gonic/gin.(*Engine).ServeHTTP
/usr/local/go/src/net/http/server.go:2947 net/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:1991 net/http.(*conn).serve
/usr/local/go/src/runtime/asm_amd64.s:1594 runtime.goexit
sitemap cron execution
1 Answers

I saw the error log, and it was clear that the error was due to an incorrect character set when creating the database. Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'

such as

create database answer default character set utf8mb4 collate utf8mb4_general_ci

The character set should be utf8mb4.