MySQL inserting Chinese characters incorrect string value solution

Source: Internet
Author: User

When the project is developed, the Chinese characters submitted by the Web form will be reported incorrect string value: ' \xf0\x90\x8d\x83\xf0\x90 ... ' exception

The reason is that MySQL encoding is caused by using show variables like ' character% ' to view the encoding of the database:

Mysql> Show variables like ' character%'- ;+--------------------------+--------------------------------------------------------+| variable_name | Value |+--------------------------+-------------------------------------- ------------------+| character_set_client | Latin1 | | character_set_connection | Latin1 | | Character_set_database | Latin1 | | Character_set_filesystem | binary | | Character_set_results | Latin1 | | Character_set_server | Latin1 | | Character_set_system | UTF8 | | Character_sets_dir | /usr/local/mysql-5.1.63-osx10.6-x86_64/share/charsets/|+--------------------------+--------------------------- -----------------------------+8 rows  inchSet (0.00 sec)

Find some solutions online: Modify the field or the table's character set to UTF8

Scenario 1, converting the data table encoding to insert Chinese characters to UTF8

Affected rows (0.35  duplicates:0  warnings:0

Scenario 2, changing the encoding format of the database, and then re-building the table

Alert Database fruitdata character set UTF8;

MySQL inserting Chinese characters incorrect string value solution

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.