简体   繁体   English

字符集 utf8mb4 collate utf8mb4_general_ci 不接受带重音的单词

[英]character set utf8mb4 collate utf8mb4_general_ci does not accept words with accents

I have a database with the character set configured for utf8mb4 and collate as utf8mb4_general_ci but when I run the command我有一个为 utf8mb4 配置的字符集并整理为 utf8mb4_general_ci 的数据库,但是当我运行命令时

CREATE TEMPORARY TABLE TESTE(
  CAMPO VARCHAR(200)
 );


INSERT INTO TESTE (CAMPO) VALUES ('é');

select * from TESTE;

it returns me the error它返回了我的错误

1 Incorrect string value: '\xE9' for column 'CAMPO' at row 9 SQL1.sql 9 20 

what happens is that I am using a LOAD DATA INFILE to INSERT values in my database and I need my table to accept accented characters发生的事情是我正在使用 LOAD DATA INFILE 在我的数据库中插入值,并且我需要我的表接受重音字符

I run this in mysql 8.0.19 and as you see in 5.7我在 mysql 8.0.19 和你在 5.7 中看到的那样运行它

CREATE TEMPORARY TABLE TESTE( CAMPO VARCHAR(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ); INSERT INTO TESTE (CAMPO) VALUES ('é');
 ✓ ✓ ✓ ✓
 select * from TESTE;
 | | CAMPO |坎普 | |:---- | |:---- | | | é | é |

db<>fiddle here db<> 在这里摆弄

both work just fine.两者都工作得很好。

check your database, Table/column somewhere you don't have the right characterset检查您的数据库,表/列在您没有正确字符集的地方

Had to change the character set of the values that i was INSERTING on my table to latin1必须将我在表上插入的值的字符集更改为 latin1

I was using我正在使用

LOAD DATA INFILE 'pathToMyFile.csv' 
INTO TABLE myTable
FIELDS TERMINATED BY ';'

so i had to add the command CHARACTER SET latin1 soo my code now is like所以我不得不添加命令CHARACTER SET latin1 soo 我的代码现在就像

LOAD DATA INFILE 'pathToMyFile.csv' 
INTO TABLE myTable
CHARACTER SET latin1
FIELDS TERMINATED BY ';'

and worked fine.并且工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 COLLATION &#39;utf8mb4_general_ci&#39; 对 CHARACTER SET &#39;binary&#39; 无效 - COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'binary' utf8mb3_general_ci 转换成 utf8mb4_general_ci - utf8mb3_general_ci into utf8mb4_general_ci 将列整理从 utf8mb4_general_ci 更改为 utf8mb4_bin 损坏表 - Change column collate from utf8mb4_general_ci to utf8mb4_bin corrupt the table mysql utf8mb4_general_ci问题 - mysql utf8mb4_general_ci issue “COLLATION 'utf8_general_ci' 对字符集 'utf8mb4' 无效” - "COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'utf8mb4'" Illuminate \\ Database \\ QueryException:SQLSTATE [HY000] [2002]连接拒绝默认字符集utf8mb4整理utf8mb4_unicode_ci - Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Connection refused default character set utf8mb4 collate utf8mb4_unicode_ci 非法混合排序规则 (utf8mb4_unicode_ci,IMPLICIT) 和 (utf8mb4_general_ci,IMPLICIT) 用于操作 &#39;=&#39; - Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '=' 排序规则将 utf8mb4_unicode_ci 更改为 utf8mb4_general_ci - Collation change utf8mb4_unicode_ci to utf8mb4_general_ci MySQL JDBC参数(utf8mb4_general_ci)是否设置正确 - Whether the MySQL JDBC parameter(utf8mb4_general_ci) is set properly 未知字符集:“ utf8mb4” - Unknown character set: 'utf8mb4'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM