MySQL warning: Incorrect string value: #39;\x96(MySQL 警告:不正确的字符串值:\x96)
问题描述
我正在尝试导入一个 CVS 文件,并在其中收到此警告:1366 不正确的字符串值:'\x96 PART ...' 列
I'm trying to import a CVS file where I get this warning: 1366 Incorrect string value: '\x96 PART...' for column
我在某处读到这是关于 4 位 utf8 字符的.但是将表和列的排序规则更改为 utf8mb4 也不起作用.
I read somewhere that this is about the 4-bit utf8 characters. But changing the collation of the table and column into utf8mb4 didn't work either.
推荐答案
十六进制 96 大概是 en-dash 的 latin1 编码> (–).但是你已经指定了 CSV 文件是 utf8 编码的(或者 utf8mb4),这个字符是 utf8 无法理解的.
The hex 96 is presumably the latin1 encoding for an en-dash (–). But you have specified that the CSV file is utf8-encoded (or utf8mb4), this character is incomprehensible to utf8.
计划 A:更改文件.(这可能不切实际.)
Plan A: Change the file. (This is probably not practical.)
计划 B:告诉 MySQL 该文件是 latin1(而不是 utf8).然后 MySQL 会将其正确转换为 utf8 编码 E28093.
Plan B: Tell MySQL that the file is latin1 (as opposed to utf8). Then MySQL will convert it correctly to the utf8-encoding E28093.
整理"与排序和比较有关;字符集"与编码"有关.
"Collation" has to do with sorting and comparing; "Character set" has to do with 'encoding'.
将此添加到我假设您正在使用的 LOAD DATA 语句中:
Add this to the LOAD DATA statement that I assume you are using:
CHARACTER SET latin1
参考.
这篇关于MySQL 警告:不正确的字符串值:'\x96的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 警告:不正确的字符串值:'\x96
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
