MySQL 中使用阿拉伯语的非法排序规则混合
我在 MySQL 中收到以下错误:
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
这是对我的应用程序中的查询的响应:
SELECT count(1) as idExists
FROM user
WHERE userName = 'خالد'
据我了解,发生这种情况是因为输入的字符对于我的表使用的排序规则类型来说是外来的。
所以我的问题是应该使用什么排序规则来处理这个问题?用户表当前设置为UTF8,我认为这是正确的,但显然我错了。它应该更改为 Latin1 还是有更好的排序规则来处理所有字符?
谢谢
I am getting the following error in MySQL:
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
this is in response to a query in my application:
SELECT count(1) as idExists
FROM user
WHERE userName = 'خالد'
As far as I understand, this is happening because the characters being entered are foreign to the collation type used for my table.
So my question is what collation should be used to handle this? The user table is currently set to UTF8 which I thought was the correct one, but obviously I'm wrong. Should it change to Latin1 or is there a better collation that handles all characters??
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望能够存储阿拉伯语(或希腊语、西里尔语、日语等),则不应使用 Latin1。 UTF-8(或其他一些 Unicode 编码)是最佳选择。
您确定表的用户名列没有设置排序规则吗?
You shouldn't use Latin1 if you want to be able to store Arabic (or Greek, Cyrillic, Japanese etc...). UTF-8 (or some other Unicode encoding) is the way to go.
Are you sure you table's username column doesn't have a collation set to it?