Skip to content

使用dble出现乱码,如何排查? #3032

Answered by PanternBao
PanternBao asked this question in Q&A
Discussion options

You must be logged in to vote

前置知识:

MySQL中的UTF-8

MySQL定义的UTF8是阉割版的,MySQL语境下的utf8mb4等价于正常语境中的UTF8。

MySQL中的字符集和参数

在谈及MySQL字符集时,还必须介绍校验集。字符集(character set)表示字符以何种规则进行编码,校验集(collation)表示字符以何种规则进行比较和排序 (例如:是否大小写敏感)。

MySQL有以下字符集相关的设置:
三组设置字符集+校验集的参数:

  • character_set_connection/collation_connection
  • character_set_server/collation_server
  • character_set_database/collation_database,此组参数已被废弃。

四个只能设置字符集的参数:

  • character_set_client
  • character_set_results
  • character_set_filesystem
  • character_set_system,此参数值固定为utf8,且不可改变。本文不涉及此项。

MySQL client中, 有一个内存变量charset_info

存储层:数据库/数据表/数据列 均由单独的字符集+校验集参数,通过CREATE语句可进行设置。MySQL文档中有详细记述。

具体每个参数的作用参考文档:https://opensource.actionsky.com/20190328-mysql-charset/

JDBC 字符集参数

  1. characterEncoding
    会设置MySQL系统变量 '…

Replies: 1 comment

Comment options

PanternBao
Jan 26, 2022
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by PanternBao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant