gpt4 book ai didi

mysql - rails mysql 编码问题/问题 - Mysql::Error: 非法混合排序规则 (latin1_swedish_ci,IMPLICIT) 和 (utf8_general_ci,COERCIBLE)

转载 作者:IT王子 更新时间:2023-10-29 00:32:00 29 4
gpt4 key购买 nike

Rails 2.3.5、Ruby 1.8.7 和 Mysql 5.1.53

我正在加载一个 csv 文件,它有一个字段,里面有 TM 符号(商标)

Tart Deco™ - 看起来像这样

我正在尝试查找事件记录:

Influencer.find(:first,:conditions => ["author_name = ? and url_discovered = ?",author_name,site_profile_url])

Mysql::Error: 操作 '=' 的排序规则 (latin1_swedish_ci,IMPLICIT) 和 (utf8_general_ci,COERCIBLE) 的非法混合:SELECT * FROM influencers WHERE (author_name = 'Tart Deco?' and url_discovered = 'http://www.joelnylund.com') 限制 1

在 ruby​​ 调试器中,字符串显示为:

p 作者姓名"酸装饰\231"

我的表格编码为“utf8_general_ci”

那我该怎么办呢?如果我存储 TM,我真的不太在意,那会很好,主要是我不想让它坏掉...

最佳答案

确保您的 table 使用 uft8 字符集:

alter table `influencers` convert to character set utf8 collate utf8_general_ci;

注意:your collation (utf8_general_ci) is not your encoding (character set) - 对 MySQL 的常见误解。

关于mysql - rails mysql 编码问题/问题 - Mysql::Error: 非法混合排序规则 (latin1_swedish_ci,IMPLICIT) 和 (utf8_general_ci,COERCIBLE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6065037/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com