字符集 character set /Mysql 遇到的问题 解决
2013-11-26 16:20
549 查看
没有必要用UTF-8存储16进制数据,采用UTF-8存储16进制数据不会增加磁盘空间的占用,但是当你使用排序(order by)、统计(group by)、隐式临时表(MySQL查询时自建的临时表)等的时候,需要耗费多达3倍的内存和硬盘空间,至少在MySQL上是这样的
所以在Mysql中存储16进制数据,用binary就好。但是,由于显示的字符集是utf8,所以看见的是乱码,于是要用hex()函数转化一下。
如果在导入sql脚本时遇到字符集无法识别的情况,在mysql命令行加入 “ --default-character-set=utf8 ”
HEX(str), HEX(N)
For a string argument str, HEX() returns
a hexadecimal string representation of str where
each character instr is
converted to two hexadecimal digits. The inverse of this operation is performed by the UNHEX() function.
For a numeric argument N, HEX() returns
a hexadecimal string representation of the value of N treated
as a longlong (BIGINT)
number. This is equivalent to CONV(N,10,16).
The inverse of this operation is performed byCONV(HEX(N),16,10).
所以在Mysql中存储16进制数据,用binary就好。但是,由于显示的字符集是utf8,所以看见的是乱码,于是要用hex()函数转化一下。
如果在导入sql脚本时遇到字符集无法识别的情况,在mysql命令行加入 “ --default-character-set=utf8 ”
HEX(str), HEX(N)
For a string argument str, HEX() returns
a hexadecimal string representation of str where
each character instr is
converted to two hexadecimal digits. The inverse of this operation is performed by the UNHEX() function.
For a numeric argument N, HEX() returns
a hexadecimal string representation of the value of N treated
as a longlong (BIGINT)
number. This is equivalent to CONV(N,10,16).
The inverse of this operation is performed byCONV(HEX(N),16,10).
mysql> SELECT 0x616263, HEX('abc'), UNHEX(HEX('abc')); -> 'abc', 616263, 'abc' mysql> SELECT HEX(255), CONV(HEX(255),16,10); -> 'FF', 255
相关文章推荐
- MySQL字符集 GBK、GB2312、UTF8区别 解决 MYSQL中文乱码问题 收藏 MySQL中涉及的几个字符集 character-set-server/default-character-set:服务器字符集,默认情况下所采用
- 关于"xampp中mysql中配置问题:Unknown initial character set index '48' received from server错误解决方法"
- mysql驱动引起的jdbc4.MySQLSyntaxErrorException: Unknown character set: 'utf8mb4'问题解决
- mysql报错问题解决Character set 'utf8mb4' is not a compiled character set
- MySQL skip-character-set-client-handshake导致的一个字符集问题
- MySQL 5.5版本解决中文乱码问题时my.ini内[mysqld]项中不能再写default-character-set=utf8
- linux中修改mysql的默认编码(character_set_server)解决插入乱码问题
- MySQL 5.5版本解决中文乱码问题时my.ini内[mysqld]项中不能再写default-character-set=utf8
- 解决MySQL 在 Java 检索遇到timestamp空值时报异常的问题
- MySQL字符集 GBK、GB2312、UTF8区别 解决MYSQL中文乱码问题
- Win10系统安装MySQL8.0.13遇到的问题及解决方法
- 解决mysql字符集乱码问题
- 重装MySQL重装遇到的问题解决办法
- MySQL的“SET NAMES xxx”字符集问题分析
- phpmyadmin里MySQL字符集:cp1252 West European (latin1) ,解决乱码问题
- 使用hibernate心得——字符串超长的解决办法(setCharacterStream出现顺序问题)
- 使用java向MySQL存储图片遇到的问题及解决
- Mysql升级到5.7后遇到的group by查询问题解决
- 编译mysql测试文件时遇到的小问题及解决方法
- MySQL字符集 GBK、GB2312、UTF8区别 解决 MYSQL中文乱码问题