MySql varchar 从 Latin1 更改为 UTF8
在 mySql 表中,我使用 Latin1 字符集将文本存储在 varchar 字段中。由于我们的网站现在在更多国家/地区得到支持,因此我们需要支持 UTF8。如果我将这些字段更改为 UTF8 会发生什么情况?这样做是否安全,或者会弄乱这些字段内的数据吗?将字段更改为 UTF8 时我需要考虑什么吗?
谢谢!
In a mySql table I'm using Latin1 character set to store text in a varchar field. As our website now is supported in more countries we need support for UTF8 instead. What will happen if I change these fields to UTF8 instead? Is it secure to do this or will it mess up the data inside these fields? Is it something I need to think about when changing the field to UTF8?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MySQL 很好地处理了这个问题:
编辑:并且没有不能存储为 utf-8 的 latin-1 字符,因此您不应该丢失任何数据
MySQL handles this nicely:
EDIT: And there are no latin-1 characters that cannot be stored as utf-8, so you shouldn't get any dataloss
数据库方面应该不会有任何问题。 MySQL 将在您进行更改时处理编码之间的数据转换。
当您向网站添加对 UTF-8 的支持时,还需要注意其他事项。
SET NAMES utf8
来完成此操作。There shouldn't be any problems on the database front. MySQL will handle the conversion of data between encodings at the time you make the change.
There are other things you need to be aware of when you add support for UTF-8 to your website.
SET NAMES utf8
when you make the connection.