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
-
: 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