Mysqldump exporting Chinese garbled characters

Source: Internet
Author: User

Mysqldump exporting Chinese garbled characters


It's all normal to check.

1, through the navicat to do the export is normal

2, then go to check the database code, see also is normal

Show variables like ' char% ';

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

| variable_name | Value |

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

| character_set_client | UTF8 |

| character_set_connection | UTF8 |

| Character_set_database | UTF8MB4 |

| Character_set_filesystem | binary |

| Character_set_results | UTF8 |

| Character_set_server | UTF8 |

| Character_set_system | UTF8 |

| Character_sets_dir | /usr/share/mysql/charsets/|


3, into the MySQL database through the command to query the statement is also able to display the normal Chinese;


4. Viewing the exported file format is Latin1 encoding (

the file encoding can be viewed directly in Vim Shell Code

    1. : Set fileencoding

)


Is it amazing????



Abnormal is through the command mysqldump command line to export are garbled, no matter with--default-character-set=utf8, still garbled

Mysqldump-h10.10.10.10-uroot--default-character-set=utf8-p Test >/tmp/test.sql


After careful analysis of the table structure, there is a blob type. This is not a strange garbled.

On the basis of the original order to add--hex-blob, fix.
The meaning of this parameter is to export binary, VARBINARY, BLOB type data in 16 binary way.
--hex-blob Dump binary strings (binary, VARBINARY, blob) in hexadecimal format.

Mysqldump-h10.10.10.10-uroot--default-character-set=utf8 --hex-blob -P test >/tmp/test.sql


In fact in our backup script has already put this parameter in, but we did not attract enough attention.


This article is from the "Holy" blog, make sure to keep this source http://holy2010.blog.51cto.com/1086044/1950813

Mysqldump exporting Chinese garbled characters

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.