ubuntu + python3 + mysql environment written in Chinese under

Error 1366-incorrect string value: \ xE7 \ x8E \ x8B for column fi

Cause Analysis:

Set the default character set of MySQL has four levels: the server level, database level, table level. The final is a field-level character set. Note that the default settings are three kinds ago, the code is not your field will eventually use this character set. Therefore, we recommend to use the show create table table; or show full fields from tableName; to check the character set of fields in the current table.

Solution:

May be the server level, database, table, modified from encoding:
1) to modify the database character set:
the ALTER DATABASE db_name the CHARACTER the SET character_name the DEFAULT [the COLLATE ...];

2) The default character set table and all the character columns (CHAR, VARCHAR, TEXT) to a new character set:
the ALTER TABLE tbl_name the CONVERT the TO character_name the CHARACTER the SET [the COLLATE ...]
as: ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

3) only changes to the table default character set:
the ALTER TABLE tbl_name the CHARACTER the SET character_name the DEFAULT [the COLLATE ...];
such as: ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

4) modify the character set field:

ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...];
如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;

Guess you like

Origin blog.csdn.net/weixin_33811961/article/details/90959303