简体   繁体   English

MySQL转储和导入不保留编码?

[英]MySQL Dump and Import not preserving encoding?

I am trying to copy a table from on MySQL database on a remote machine to another MySQL database on my local machine. 我正在尝试将远程计算机上的MySQL数据库中的表复制到本地计算机上的另一个MySQL数据库。 I noticed that after importing the dump to my local machine, there were characters like ’ instead of single quotes. 我注意到在将转储导入我的本地机器后,有一些字符,如•,而不是单引号。

I assumed this was an encoding issue, so I went into both databases and ran show create table posts , near the end of both, I saw CHARSET=utf8 . 我认为这是一个编码问题,所以我进入了两个数据库并运行show create table posts ,接近两个结尾,我看到了CHARSET=utf8 Also, I ran file -i on the dump file, both before and after scp ing it to my local machine, and they were both utf8. 另外,我跑了file -i之前和之后的转储文件, scp是荷兰国际集团,以我的本地机器,他们都是UTF8。

However, when I import this file, I get this before: 但是,当我导入这个文件时,我之前得到了这个:

  attendees—policy makers, 

and after: 之后:

  attendees—policy makers,

I am not sure why this is happening, everything is using utf8, what am I missing? 我不确定为什么会这样,一切都在使用utf8,我错过了什么?

EDIT: I am using mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (x86_64) remotely, and mysql Ver 14.14 Distrib 5.5.25a, for osx10.7 (i386) locally. 编辑:我正在使用mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (x86_64)远程mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (x86_64) ,以及mysql Ver 14.14 Distrib 5.5.25a, for osx10.7 (i386)本地。

On both systems you must check that your connection encoding is correct: 在两个系统上,您必须检查连接编码是否正确:

SHOW VARIABLES LIKE 'character_set_%'

Usually seeing characters like that is the result of double-encoding. 通常看到这样的字符是双重编码的结果。 Make sure you can match up the connection and client encoding to be exactly the same. 确保您可以将连接和客户端编码匹配完全相同。 There is a number of command line options that can facilitate this, or if you're using a driver or client, something in there can tweak it. 有许多命令行选项可以促进这一点,或者如果你正在使用驱动程序或客户端,那里的东西可以调整它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM