When MySQL inserts Chinese into the table, it appears: incorrect string value error

Source: Internet
Author: User

When MySQL inserts Chinese into the table, it appears:incorrect string value error, because the character set does not support Chinese. The workaround is to change the character set to GBK, or UTF-8.

    First, modify the default character set of the database
 DEFAULT charcter  SET character_name [COLLATE ...    
     Example:ALTER TABLEdb_mysql DEFAULT charcter SET GBK
             notes:(Collate is a character set check, can be ignored when set, MySQL will be automatically set to the corresponding default value)     Second, modify the default character set of the table  ALTER TABLE table_name DEFAULT CHARACTER SET character_name[COLLATE ...]      Example:ALTER TABLET_userDEFAULT CHARACTER SETGbk Third, Modify the morning character set for a field in a table   ALTER TABLE table_name change Field field Field_type CHARACTER SET Character_na Me [COLLATE ...]  Example: ALTER TABLET_user ChangeWname WnameVARCHAR(20) CHARACTER SETGbk Four, Modify the default character set for the table and the character set for all columns:

ALTER TABLE table_name CONVERT to CHARACTER SET character_name

    

Example:ALTER TABLE t_user CONVERT to CHARACTER SET GBK

When MySQL inserts Chinese into the table, it appears: incorrect string value error

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.