日期:2014-05-16 浏览次数:20424 次
?
?
???? 案例如下:
?
?
???? A机器的mysql数据库中的database Test编码为gbk,B机器的characterset如下:
?
mysql> show variables like "%character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+
?
首先,从A中导出数据:
?
mysqldump -u User -p Password --default-character-set=utf8 Test > test.sql
?
然后,在B机器上
?
mysql -u User -p Password -e "use Test;set character_set_database=gbk; source test.sql"?