[英]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 |
坎普 | |:---- |
|:---- | |
| é |
é |
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.