V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
? MySQL 5.5 Community Server
? MySQL 5.6 Community Server
? Percona Configuration Wizard
? XtraBackup 搭建主从复制
Great Sites on MySQL
? Percona
? MySQL Performance Blog
? Severalnines
推荐管理工具
? Sequel Pro
? phpMyAdmin
推荐书目
? MySQL Cookbook
MySQL 相关项目
? MariaDB
? Drizzle
参考文档
? http://mysql-python.sourceforge.net/MySQLdb.html
nowheretoseek
V2EX  ?  MySQL

怎么让 mysql 支持 cjk 的 B-I 区?

  •  
  •   nowheretoseek · 11 天前 · 661 次点击

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    基本区和 A 区都是\u....的格式,B 区开始都是\u000.....了,发现 mysql 查询中 where 条件中有 B 区后面的字符,就会查询失败,具体症状是查出非常多的行,条件未被使用。

    请问该怎么做?我试了 char 、undex 函数,还是一样的问题。

    目前用的版本是 5.7.28 ,数据表和字段的校对规则都是 utf8mb4_general_ci,Google 后操作的一个语言支持查询结果如下:

    SELECT CHARACTER_SET_NAME, DESCRIPTION
           FROM INFORMATION_SCHEMA.CHARACTER_SETS
           WHERE DESCRIPTION LIKE '%Chin%'
           OR DESCRIPTION LIKE '%Japanese%'
           OR DESCRIPTION LIKE '%Korean%'
           ORDER BY CHARACTER_SET_NAME;
    
    CHARACTER_SET_NAME	DESCRIPTION
    big5	Big5 Traditional Chinese
    cp932	SJIS for Windows Japanese
    eucjpms	UJIS for Windows Japanese
    euckr	EUC-KR Korean
    gb18030	China National Standard GB18030
    gb2312	GB2312 Simplified Chinese
    gbk	GBK Simplified Chinese
    sjis	Shift-JIS Japanese
    ujis	EUC-JP Japanese
    
    第 1 条附言  ·  11 天前
    将 collation 改为 utf8mb4_bin 解决了该问题,详见 [sql - How can I search by emoji in MySQL using utf8mb4? - Stack Overflow]( https://stackoverflow.com/questions/41147829/how-can-i-search-by-emoji-in-mysql-using-utf8mb4)
    2 条回复  ?  2024-04-26 21:15:53 +08:00
    nowheretoseek
        1
    nowheretoseek  
    OP
       11 天前
    补充,问题是 select 时出现的,insert 并无问题; collation 改为 utf8mb4_unicode_ci 后,问题依旧。
    nowheretoseek
        2
    nowheretoseek  
    OP
       11 天前
    应该跟驱动程序及其配置也没有关系,在 php 、pyton 或者 mysql 终端下,问题是一样的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1067 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 22:07 · PVG 06:07 · LAX 15:07 · JFK 18:07
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com