当前位置:网站首页>MySQL insert Chinese error

MySQL insert Chinese error

2022-06-26 08:11:00 Painted horse

Mysql Error inserting Chinese

Inserting Chinese will report an error , But there will be no error when inserting English .
error analysis : Maybe the encoding format is not utf8 Caused by the .

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-kwDenRxS-1633451209914)(D:\ desktop \ note \mysql\ picture \image-20211005234303144.png)]

terms of settlement : Modify encoding format

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-vgHoRz1W-1633451209915)(D:\ desktop \ note \mysql\ picture \image-20211005234522794.png)]

Modify the encoding format of the character set and the encoding format of the arrangement order : As shown in the figure below

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Z4CB5w4g-1633451209915)(D:\ desktop \ note \mysql\ picture \image-20211005234701172.png)]

After modification, test and insert Chinese . If not, modify the database coding format

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Dmnfqt6f-1633451209916)(D:\ desktop \ note \mysql\ picture \image-20211005235230399.png)]

It is amended as follows :

 Insert picture description here

After revising , If the test finds that it doesn't work Open the command line interface : Input show create table user;

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ZBZI79xl-1633451209918)(D:\ desktop \ note \mysql\ picture \image-20211005235142459.png)]

Find out name and email The encoding format of is latin1 No utf8, But the default encoding format has changed to utf8 了

Therefore, you need to modify the coding format of the corresponding column

Use the following command to modify user The coding format in the table

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-MOT1tVI0-1633451209918)(D:\ desktop \ note \mysql\ picture \image-20211006000748710.png)]

View after modification user Table coding format . I found that I didn't do what you just did latin1 了 . Test it again

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-h7aaKLAp-1633451209918)(D:\ desktop \ note \mysql\ picture \image-20211006000836208.png)]

test result :

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-jYJyH4sx-1633451209919)(D:\ desktop \ note \mysql\ picture \image-20211006000935037.png)]

Successfully inserted Chinese .

remarks

After modifying the encoding format, you need to restart mysql database
Restart command :MySQL

net stop mysql Service name of 

net start mysql Service name of 

appendix :

mysql Modify the coding format of database tables and fields in tables

Modify the coding format of all fields in a table

alter table tablename convert to character set utf8;

Change the encoding format of the table

ALTER TABLE tablename DEFAULT CHARACTER SET utf8;

Modify the encoding format of the field

ALTER TABLE tablename CHANGE Field name 1 Field name 2 VARCHAR(36) CHARACTER SET utf8 NOT NULL;

CHANGE Field name 1 Field name 2 VARCHAR(36) CHARACTER SET utf8 NOT NULL;

原网站

版权声明
本文为[Painted horse]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170604201085.html