FAQ Series | UTF8 Table store Latin1 garbled character conversion

Source: Internet
Author: User

There is a data table on the line, the character set is UTF8, but because of the reason of the environment is not unified, causes the data table to actually store the content is the latin1 inside code the data.
In other words, the data of the latin1 character set is actually stored through the UTF8 shell.
In this case, you need to be aware of several character set configurations:

    • The Client Terminal tool (SECURECRT) displays the character set as: Utf-8,

    • Under Linux Terminal (term), set the lang environment variable to: en_US. UTF-8, or ZH_CN. UTF-8,

    • After connecting to MySQL, set the client/connect character set to: Latin1 (set names latin1).

When the above settings are completed, the Chinese will be displayed correctly in the MySQL CLI client on the Linux command line.
In order to unify, it is necessary to transfer the internal code of these data to UTF8, which can be done in the following steps:

    • Export the raw data with the latin1 character set, ensuring that the local client (Chinese environment) can be viewed normally with a text editor.

    • The text editor is saved as the Utf-8 character set after uploading to the server side or copying the data directly to

    • Linux terminal, create a new file, directly paste the data in,

    • Clear the data table (truncate), modify the character set (ALTER TABLE XX default charset = UTF8),

    • Imports text into a data table.

The above is a rather clumsy manual method to demonstrate the whole process.
If the table stores more complex data, it is recommended to write a program to convert, after all, the code is different, not directly online conversion.


--------------------------------------Split Line--------------------------------------

http://zhishuedu.comTraining is a professional quality training brand jointly launched by senior MySQL expert Ye Jinlong and Wu Bingxi, with MySQL dba combat optimization and Python devops Development course, which is the most conscientious and The most quality training courses.


This article is from the "Lao Ye teahouse" blog, please be sure to keep this source http://imysql.blog.51cto.com/1540006/1879765

FAQ Series | UTF8 Table store Latin1 garbled character conversion

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.