django字符集与MySQL的奇怪 [英] django character set with MySQL weirdness

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

问题描述

我看到

OperationalError (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")

看起来我的一些变量是UTF8字符串

It looks like some of my variables are UTF8 strings

'name':'p\xc7\x9d\xca\x87\xc9\x9f\xc4\xb1\xc9\xa5s徽章'

'name': 'p\xc7\x9d\xca\x87\xc9\x9f\xc4\xb1\xc9\xa5s Badge'

这是一个配置问题吗?如果是这样,我该如何解决呢?我想处理所有的Unicode(我想)。

Is this a configuration issue? If so, how can i solve it? I'd like to handle everything in Unicode (I think).

推荐答案

看来你的数据库默认为latin1_swedish_ci,因此不能接受所有的utf8字符。您需要将MySQL数据库表的配置更改为使用utf8_general_ci。有关这方面的好博客(包含工具的链接)可以在 MySQL性能博客

It appears your database is defaulted to latin1_swedish_ci, and therefore cannot accept all utf8 characters. You need to change the configuration of the MySQL database tables to use utf8_general_ci. A good blogpost about this (with links to a tool) can be found at MySQL Performance Blog

这篇关于django字符集与MySQL的奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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