set - MySQL blob dump to tab delimited files -
i migrating mysql 5.1 database in amazon's ec2, , having issues tables longblob datatype use image storage. basically, after migration, data in longblob column different size, due fact character encoding seems different.
first of all, here example of before , after migration:
old:
x??]]??}?_ѕ??d??i|w?%?????q$??+?
new:
x��]]����_ѕ��d��i|w�%�����q$��+�
i checked character set variables on both machines , identical. checked 'show create table' , identical well. client's both connecting same way (no set names, or specifying character sets).
here mysqldump command used (i tried without --hex-blob well):
mysqldump --hex-blob --default-character-set=utf8 --tab=. db_name
here how loaded data:
mysql db_name --default-character-set=utf8 -e "load data infile 'example.txt' table example;"
here mysql character set variables (identical):
old:
+--------------------------+----------------------------+ | variable_name | value | +--------------------------+----------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
new:
+--------------------------+----------------------------+ | variable_name | value | +--------------------------+----------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
i'm not sure else try able run mysqldump , have blob data identical on both machines. tips appreciated.
the issue seems bug in mysql (http://bugs.mysql.com/bug.php?id=27724). solution not use mysqldump, write own select outfile script tables have blob data. here example:
select coalesce(column1, @nullval), coalesce(column2, @nullval), coalesce(hex(column3), @nullval), coalesce(column4, @nullval), coalesce(column5, @nullval) table outfile '/mnt/dump/table.txt' fields terminated '\t' lines terminated '\n';
to load data:
set names utf8; load data infile '/mnt/dump/table.txt' table table fields terminated '\t' lines terminated '\n' (column1, column1, @column1, column1, column1) set data = unhex(@column1)
this loads blob data correctly.
Comments
Post a Comment