教您如何将不同的MySQL字符集转化成统一的字符集
时间:2025-11-05 03:09:05 出处:IT科技类资讯阅读(143)

复制After an upgrade to MySQL 4.1,教何 the statement fails: mysql> SELECT SUBSTRING_INDEX(USER(),@,1); ERROR 1267 (HY000): Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation substr_index The reason this occurs is that usernames are stored using UTF8 (see section 11.6 UTF8 for Metadata). As a result, the USER() function and the literal string @ have different character sets (and thus different collations): mysql> SELECT COLLATION(USER()), COLLATION(@); +-------------------+-------------------+ | COLLATION(USER()) | COLLATION(@) | +-------------------+-------------------+ | utf8_general_ci | latin1_swedish_ci | +-------------------+-------------------+ One way to deal with this is to tell MySQL to interpret the literal string as utf8: mysql> SELECT SUBSTRING_INDEX(USER(),_utf8@,1); +------------------------------------+ | SUBSTRING_INDEX(USER(),_utf8@,1) | +------------------------------------+ | root | +------------------------------------+ Another way is to change the connection character set and collation to utf8. You can do that with SET NAMES utf8 or by setting the character_set_connection and collation_connection system variables directly. 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.
分享到:
温馨提示:以上内容和图片整理于网络,仅供参考,希望对您有帮助!如有侵权行为请联系删除!
猜你喜欢
- 以其他盘装系统教程(一步一步教你如何在其他硬盘分区上安装全新的操作系统)
- 佳能CP910的卓越效果(佳能CP910的高质量打印让照片更加真实细腻)
- 金和田680GTX——高性能显卡的首选之一(全面解析金和田680GTX的性能优势和应用领域)
- 三星云盘(探索三星云盘的功能与优势)
- 解决galgame电脑运行错误的方法(探索电脑运行错误的原因与解决方案)
- 实木手机壳的优点与选择指南(打造个性化手机外观,保护手机双重之选)
- 台电平板P98,性能卓越的全能娱乐利器(颠覆你对平板的认知,P98带给你不一样的体验)
- 佳能310HS是一款出色的相机选择(探索佳能310HS的精彩功能和拍摄效果)
- ROG显卡安装教程(ROG显卡安装教程及注意事项,助你提升游戏体验)