简体   繁体   English

MySQL的。 无法将俄语字符插入类型为VARCHAR(45)的列中

[英]MySQL. Can't insert russian characters into column with a type VARCHAR(45)

I have a problem when trying to execute this line in MySQL (Workbench): 尝试在MySQL(Workbench)中执行此行时遇到问题:

INSERT INTO classification (`Type`, `Subtype`) VALUES ("тип", "подтип");

I have tried to set different charsets for table classification : cp1251, utf-8, utf8mb4, cp1251_bin. 我尝试为表classification设置不同的字符集:cp1251,utf-8,utf8mb4,cp1251_bin。

This is a table with all charsets in my database that I have found, maybe it will help you: 这是一个表,其中包含我在数据库中找到的所有字符集,也许会对您有所帮助:

在此处输入图片说明

UPD. UPD。 I have found a solution. 我找到了解决方案。 However, I had to change my table, so now the table risk is an edited table classification . 但是,我必须更改表,所以现在表risk是已编辑的表classification The result of SHOW CREATE TABLE risk is: SHOW CREATE TABLE risk的结果是:

 'CREATE TABLE `risk` (
  `IdRisk` int(11) NOT NULL AUTO_INCREMENT,
  `IdSubtype` int(11) DEFAULT NULL,
  `Content` varchar(4000) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`IdRisk`),
  KEY `FK_subtype_risk_idx` (`IdSubtype`),
  CONSTRAINT `FK_subtype_risk` FOREIGN KEY (`IdSubtype`) REFERENCES `subtype` (`IdSubtype`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=latin1'

Can't find the solution to this issue. 找不到解决此问题的方法。 I'm hope that someone knows a solution to it. 我希望有人知道解决方案。

Thank You! 谢谢!

The CHARACTER SET for the table is the default for columns in the table. 该表的CHARACTER SET是该表中列的默认设置 Please provide SHOW CREATE TABLE so we can verify what the columns are set to. 请提供SHOW CREATE TABLE以便我们可以验证列设置为什么。

What is the encoding of the bytes in the client? 客户端中字节的编码是什么? cp1251 is different than utf8 ; cp1251utf8不同; utf8mb4 == utf8 for Russian. utf8mb4 == utf8 (俄语)。

In what way are things bad? 事情以什么方式不好? Based on the symptom, see this for specific tips on what else might be set incorrectly. 根据症状,看到其他可能被错误地设置具体的提示。

Perhaps it was your change to NVARCHAR that forced CHARACTER SET utf8 on the columns? 也许是您对NVARCHAR所做的更改导致在列上强制使用CHARACTER SET utf8

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM