MySQL 5 的 UTF8 问题 [英] UTF8 problem with MySQL 5

查看:38
本文介绍了MySQL 5 的 UTF8 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的 WordPress 博客和 phpBB 论坛迁移到一个新的托管服务器.我正在使用 phpMyAdmin 从上一个站点的数据库中导入 SQL 脚本.

I'm migrating my WordPress blog and phpBB Forum into a new hosting server. I am using phpMyAdmin to import the SQL script from the database in the previous site.

当我用 Kate 打开 .sql 脚本时,它说它使用 UTF8 作为编码.我在新服务器导入sql的时候,在phpMyAdmin里面有选择编码的选项,这里默认选择utf8.

When I open the .sql script with Kate, it says it uses UTF8 as encoding. When I import the sql in the new server, I have the option in phpMyAdmin to choose the encoding, where utf8 is selected by default.

然而,当我完成导入数据库时​​,我直接在phpMyAdmin中阅读了帖子文本,并看到了诸如é",ñ"等未被解释"并被替换为奇怪字符的字符插入.

Still, when I finish importing the database, I read the posts text directly in phpMyAdmin, and see characters such as "é", "ñ", etc. which haven't been "interpreted" and been replaced with weird characters insted.

我可以看到我的 WordPress 安装也不起作用.显然这个编码有问题,但我认为问题出在 MySQL 数据库或 phpMyAdmin 而不是 WordPress.

I can see my WordPress installation is not working also. Apparently there's a problem with this encoding thing, but I think the problem is in the MySQL database or phpMyAdmin and not WordPress.

MySQL 的版本几乎相同,即 MySQL 5,但版本不同.还有,迁移论坛数据库的时候没有问题,所以这更奇怪......

The versions of MySQL are practically the same, MySQL 5, but a different revision. Also, there was no problem when migrating the forum database, so this is even stranger...

我不知道如何解决这个问题...欢迎提出任何想法.

I'm lost as to how to fix this... Any ideas are welcome.

推荐答案

您是否尝试添加

SET NAMES 'utf8';

到你的 sql 转储?

to your sql dump?

utf8 或一般编码的事情是,为了成功,您必须确保:

The thing with utf8 or encodings in general is that in order to be successfull, you have to make sure that:

  • 文件采用utf8编码,没有签名
  • mysql 服务器的默认编码设置为 utf8
  • 连接是 utf8(这就是您将 SET NAMES 'utf8' 放入 sql 文件的原因).
  • 所有表和列都有正确的编码和字符集
  • 你所有的网络文件也必须是 utf8 编码的.仅添加正确的标题是行不通的.您必须打开文件,检查编码是否为 utf8,如果不是,则剪切所有内容,将编码更改为 utf8 并将所有内容粘贴回去.如果您只是更改编码并保存文件,它不起作用!

这篇关于MySQL 5 的 UTF8 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆