Skip to content
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

8.0 字符集设置为utf8,会出现Unknown charset utf8mb3问题 #531

Open
dibrother opened this issue Nov 22, 2022 · 9 comments
Open

8.0 字符集设置为utf8,会出现Unknown charset utf8mb3问题 #531

dibrother opened this issue Nov 22, 2022 · 9 comments
Labels
wontfix This will not be worked on

Comments

@dibrother
Copy link

dibrother commented Nov 22, 2022

描述
在进行8.0的数据变更时,当设置character_set_server=utf8, check时出现 Unknown charset utf8mb3

重现

库表创建

-- 建库表
create database aaa;
create table t1 (id int primary key);

-- 字符集状态:
root@localhost [(none)]>show variables like '%char%';
+--------------------------+----------------------------------------------------------------+
| Variable_name            | Value                                                          |
+--------------------------+----------------------------------------------------------------+
| character_set_client     | utf8mb4                                                        |
| character_set_connection | utf8mb4                                                        |
| character_set_database   | utf8mb3                                                        |
| character_set_filesystem | binary                                                         |
| character_set_results    | utf8mb4                                                        |
| character_set_server     | utf8mb3                                                        |
| character_set_system     | utf8mb3                                                        |
| character_sets_dir       | /usr/local/mysql-5.7.40-linux-glibc2.12-x86_64/share/charsets/ |
+--------------------------+----------------------------------------------------------------+
8 rows in set (0.00 sec)

config相关

goinctpion 使用默认的 config配置(未更改任何项)

测试用例

[root@test151 goinc]# cat test.py 
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import pymysql
import prettytable as pt
tb = pt.PrettyTable()

sql = '''/*--user=test_user;--password=123456;--host=127.0.0.1;--check=1;--port=3306;*/
inception_magic_start;
use aaa;
ALTER TABLE `t1`
    add `v1` varchar(20) ,
    add `v2` varchar(20) DEFAULT '0' COMMENT 'v2';

inception_magic_commit;'''

conn = pymysql.connect(host='127.0.0.1', user='', passwd='',
                       db='', port=4000, charset="utf8mb4")
cur = conn.cursor()
ret = cur.execute(sql)
result = cur.fetchall()
cur.close()
conn.close()

tb.field_names = [i[0] for i in cur.description]
for row in result:
    tb.add_row(row)
print(tb)

测试结果

[root@test151 goinc]# python test.py 
time="2022/11/22 18:01:43.601" level=info msg="con:7 new connection 127.0.0.1:39512" file=server.go func=onConn line=319
time="2022/11/22 18:01:43.621" level=info msg="con:7 close connection" file=server.go func=func1 line=321
+----------+---------+-------------+-----------------+--------------------------+---------------------------------------------------+---------------+--------------+---------------+--------------+---------+-------------+
| order_id |  stage  | error_level |   stage_status  |      error_message       |                        sql                        | affected_rows |   sequence   | backup_dbname | execute_time | sqlsha1 | backup_time |
+----------+---------+-------------+-----------------+--------------------------+---------------------------------------------------+---------------+--------------+---------------+--------------+---------+-------------+
|    1     | CHECKED |      0      | Audit Completed |           None           |                      use aaa                      |       0       | 0_0_00000000 |      None     |      0       |   None  |      0      |
|    2     | CHECKED |      2      | Audit Completed | Unknown charset utf8mb3. |                  ALTER TABLE `t1`                 |       0       | 0_0_00000001 |      None     |      0       |   None  |      0      |
|          |         |             |                 | Unknown charset utf8mb3. |                 add `v1` varchar(20) ,            |               |              |               |              |         |             |
|          |         |             |                 |                          |     add `v2` varchar(20) DEFAULT '0' COMMENT 'v2' |               |              |               |              |         |             |
+----------+---------+-------------+-----------------+--------------------------+---------------------------------------------------+---------------+--------------+---------------+--------------+---------+-------------+

环境

  • 数据库: [mysql]
  • 版本: [8.0.25/8.0.30]
  • goinc版本:1.2.4
@xubodreamsky
Copy link

这个issue没有人解决么

@1454513232
Copy link

我也遇到这个问题了,使用v1.3.0最新版本的goInception,阿里云的RDS默认设置
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb3
character_set_filesystem binary
character_set_results
character_set_server utf8mb3
character_set_system utf8mb3
character_sets_dir /u01/mysql80_20220730/share/charsets/

提交建表check就会报Unknown charset utf8mb3

hanchuanchuan added a commit that referenced this issue Mar 20, 2023
fix: 修复MySQL v8.0当database字符集为utf8mb3时审核失败的问题(#531)
@hanchuanchuan
Copy link
Owner

已修复. 请升级到版本 v1.3.0-68.
也可修改MySQL参数character_set_database为utf8mb4,该更新是安全的,不会影响旧的库/表,且兼容utf8字符集.

@zhangguangrui1991
Copy link

character_set_database设置为utf8mb4,
使用v1.3.0-68版本,普通审核无异常。但针对表字符集为utf8mb3的表进行add column操作审核时,仍会出现unknown charset utf8mb3.

create table test (
id int ,
name varicahr(20),
city_code varchar(5),
primary key (id)
) engine=innodb default character=utf8mb3;

@NoskyOrg
Copy link

NoskyOrg commented Apr 14, 2023

mysql 8.0.32 出现和楼上一样的问题

另外这个参数为什么没有生效,
support_charset = "utf8,utf8mb4,utf8mb3"

debug日志粒度太粗也没看出有什么问题

time="2023/04/14 17:27:51.150" level=info msg="con:1 new connection 10.189.。。。。。:。。。" file=server.go func=onConn line=319
time="2023/04/14 17:27:51.151" level=debug msg="con:0 ActivePendingTxn select HIGH_PRIORITY * from mysql.global_variables where variable_name in ('autocommit', 'sql_mode', 'max_allowed_packet', 'time_zone', 'block_encryption_mode', 'tidb_skip_utf8_check', 'tidb_index_join_batch_size', 'tidb_index_lookup_size', 'tidb_index_lookup_concurrency', 'tidb_index_lookup_join_concurrency', 'tidb_index_serial_scan_concurrency', 'tidb_hash_join_concurrency', 'tidb_projection_concurrency', 'tidb_hashagg_partial_concurrency', 'tidb_hashagg_final_concurrency', 'tidb_backoff_lock_fast', 'tidb_constraint_check_in_place', 'tidb_ddl_reorg_worker_cnt', 'tidb_opt_insubquery_unfold', 'tidb_distsql_scan_concurrency', 'tidb_max_chunk_size', 'tidb_enable_cascades_planner', 'tidb_retry_limit', 'tidb_disable_txn_auto_retry')" file=adapter.go func=buildExecutor line=278
time="2023/04/14 17:27:51.153" level=debug msg=mysqlServerVersion file=session_inception.go func=mysqlServerVersion line=1685
time="2023/04/14 17:27:51.155" level=debug msg="db version: 80032" file=session_inception.go func=mysqlServerVersion line=1739
time="2023/04/14 17:27:51.155" level=debug msg=setSqlSafeUpdates file=session_inception.go func=setSqlSafeUpdates line=1944
time="2023/04/14 17:27:51.156" level=debug msg=setLockWaitTimeout file=session_inception.go func=setLockWaitTimeout line=1966
time="2023/04/14 17:27:51.156" level=debug msg=initDisableTypes file=session_inception.go func=initDisableTypes line=8589
time="2023/04/14 17:27:51.156" level=debug msg=processCommand file=session_inception.go func=processCommand line=557
time="2023/04/14 17:27:51.156" level=debug msg=executeInceptionSet file=session_inception.go func=executeInceptionSet line=5928
time="2023/04/14 17:27:51.156" level=debug msg=initDisableTypes file=session_inception.go func=initDisableTypes line=8589
time="2023/04/14 17:27:51.156" level=info msg="inception set session merge_alter_table = true, check_primary_key = true" file=session_inception.go func=executeInc line=440
time="2023/04/14 17:27:51.156" level=debug msg=processCommand file=session_inception.go func=processCommand line=557
time="2023/04/14 17:27:51.156" level=debug msg=checkAlterTable file=session_inception.go func=checkAlterTable line=3166
time="2023/04/14 17:27:51.161" level=debug msg=mysqlCheckField file=session_inception.go func=mysqlCheckField line=4125

@NoskyOrg
Copy link

session/common.go

var charSets = map[string]int{
	"armscii8": 1,
	"ascii":    1,
	"big5":     2,
	"binary":   1,
	"cp1250":   1,
	"cp1251":   1,
	"cp1256":   1,
	"cp1257":   1,
	"cp850":    1,
	"cp852":    1,
	"cp866":    1,
	"cp932":    2,
	"dec8":     1,
	"eucjpms":  3,
	"euckr":    2,
	"gb18030":  4,
	"gb2312":   2,
	"gbk":      2,
	"geostd8":  1,
	"greek":    1,
	"hebrew":   1,
	"hp8":      1,
	"keybcs2":  1,
	"koi8r":    1,
	"koi8u":    1,
	"latin1":   1,
	"latin2":   1,
	"latin5":   1,
	"latin7":   1,
	"macce":    1,
	"macroman": 1,
	"sjis":     2,
	"swe7":     1,
	"tis620":   1,
	"ucs2":     2,
	"ujis":     3,
	"utf16":    4,
	"utf16le":  4,
	"utf32":    4,
	"utf8":     3,
	"utf8mb3":  3,
	"utf8mb4":  4,
}

@hanchuanchuan
Copy link
Owner

请升级到 v1.3.0-72 版本后重试

@NoskyOrg
Copy link

NoskyOrg commented May 4, 2023

请升级到 v1.3.0-72 版本后重试

hao,我试试

@stale
Copy link

stale bot commented Jun 18, 2023

由于此问题没有最近的活动,因此已被自动标记为陈旧。如果没有进一步的活动,会作为不活跃issue关闭。感谢你对本项目的贡献。 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants