我已经将数据库从 MySQL 5.0 (Fedora Core 7) 迁移到 MariaDB 10.5 到最新的 OS Rocky 9.1。就 ASCII 1 字节文本数据而言,没有问题。现在,我的某个数据库中有大量 2 字节字符。俄文、韩文、日文、中文字母。我没有成功将数据编译到 MariaDB 10.5 中。我可以在编译数据时告诉 MariaDB,请处理包含 2 字节字符的数据。或者我必须调整计算机的环境设置以适应 2 字节字母。
无论如何,我发布了我的 .sql 代码。你要不要看一下?
DROP TABLE IF EXISTS editors;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE editors (
id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
editor_id SMALLINT UNSIGNED,
language CHAR(100),
name CHAR(250),
dummy_field CHAR(10),
PRIMARY KEY(id)
);
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('1', 'cn:', 'Gengjie Yang', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('2', 'de:', 'Herb Wirtz', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('3', 'en:', 'Diane Gegala', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('4', 'en:', 'Maurice Barnfather', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('5', 'en:', 'Florence Smith', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('6', 'es:', 'Felix Sutherland', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('7', 'es:', 'Enrique Cob', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('8', 'fr:', 'Gina Loyonnet', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('9', 'it:', 'Dr. John Termini : Daniela Castanotto', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('10', 'kr:', '수김선생 (Sue B. Kim)', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('11', 'pt:', 'Dr. Lilicca Moreira', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('12', 'ru:', 'Тимур Мукминов (Timur Mukminov)', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('13', 'ru:', 'Даша Авдулова (Dasha Avdulova)', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('14', 'it:', 'Grazia Manzone', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('15', 'de:', 'Herb Bauer', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('16', 'en:', 'Bill Reardon', 'ZZZ' );
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('17', 'es:', 'Mario Araujo, Prs.', 'ZZZ' );
然后,我收到了 MariaDB 的抱怨消息,指出第 22、24 和 25 行导致了错误。而其余行则正常插入。
很明显,仅 Hangul Letter 第 22 行和 Russian Letter 第 24 和 25 行出现错误。
我不知道如何告诉或配置MariaDB 10.5以便顺利接受2字节字母?您能建议任何可能的方法来修复此错误吗?
尝试用这种方式创建表:
CREATE TABLE editors (
id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
editor_id SMALLINT UNSIGNED,
language CHAR(100),
name CHAR(250),
dummy_field CHAR(10),
PRIMARY KEY(id)
)
CHARACTER SET 'utf8'
COLLATE 'utf8mb3_czech_ci';
然后尝试
INSERT INTO editors ( editor_id, language, name, dummy_field ) VALUES ('12', 'ru:', 'Тимур Мукминов (Timur Mukminov)', 'ZZZ' );
https://mariadb.com/kb/en/setting-character-sets-and-collations/