Mysql Import Japanese data garbled problem

Source: Internet
Author: User
Tags mysql import

After doing the data migration, it is found that Japanese data is garbled through UI, and it is normal to modify Japanese directly through the UI.

After checking the information, the MySQL character set functions as follows:

MySQL Character set settings

• System Variables:
character_set_server: Default internal operation character Set
–character_set_client: The character set used by the client source data
–character_set_connection: Connection Layer Character Set
–character_set_results: Query result Character Set
–character_set_database: The default character set for the currently selected database
–character_set_system: System metadata (field name, etc.) character set
– There are also variables that begin with Collation_ to describe the character Fu She.

So:

mysql> SHOW VARIABLES like ' collation_% ';

+----------------------+-----------------+

| variable_name | Value |

+----------------------+-----------------+

| collation_connection | Utf8_general_ci |

| Collation_database | Utf8_general_ci |

| Collation_server | Latin1_swedish_ci|

+----------------------+-----------------+

3 Rows in Set (0.00 sec)

The connection character set is established through the JDBC configuration, so there is no problem with the Japanese through the UI:

jdbc\:mysql\://10.1.0.198\:3306/mytestui?zerodatetimebehavior\=converttonull&useunicode\=true& Characterencoding\=utf-8

When importing data, MySQL uses the default character set for import operations, because the connection character set is not explicitly specified , and the default character set is latin1_swedish_ci:

Mysql-h127.0.0.1-umyaccount-p <./patch.sql

Solution 1:

Modify the system's default character set to Utf-8

Solution 2:

When importing SQL files, specify the character set:

mysql-h127.0.0. -umyaccount-p <.patch.sql --default-character-set=utf8

Mysql explain:

Use charset_name as the default character set for the client and connection.
A common issue that can occur when the operating system uses UTF8 or anothermulti-byte characterset are that output from th E MySQL client is formatted incorrectly, due tothe fact and the MySQL client uses the latin1 character set by default. Youcan usually fix such issues by using this option to force the client to use Thesystem character set instead

Mysql Import Japanese data garbled problem

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.