简体   繁体   中英

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):

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

I have tried to set different charsets for table 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. I have found a solution. However, I had to change my table, so now the table risk is an edited table classification . The result of SHOW CREATE TABLE risk is:

 '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. Please provide SHOW CREATE TABLE so we can verify what the columns are set to.

What is the encoding of the bytes in the client? cp1251 is different than utf8 ; utf8mb4 == utf8 for Russian.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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