首页 > 数据库 >MySQL variables:binary-as-hex

MySQL variables:binary-as-hex

时间:2024-09-26 16:21:32浏览次数:3  
标签:binary ... -- variables hex CHAR mysql

不注意到这个变化的话,还挺折腾人的。

在MySQL 8.0.19 Release Notes里,有这么一段话:

When the mysql client operates in interactive mode, the --binary-as-hex option now is enabled by default. In addition, output from the status (or \s) command includes this line when the option is enabled implicitly or explicitly。To disable hexadecimal notation, use --skip-binary-as-hex (Bug #24432545)

意思是如果用mysql客户端进入交互模式,那么默认启用参数 --binary-as-hex,执行 status或 \s时能看到下面这样的标记:

[[email protected]]> \s
...
Binary data as: Hexadecimal
...
Threads: 1  Questions: 88...

可以在启动客户端时加上--skip-binary-as-hex关闭这个参数。

那么加上参数--binary-as-hex后,对交互式客户端会有什么影响呢?

先看下文档里的解释:

When this option is given, mysql displays binary data using hexadecimal notation (0xvalue).

也就是说,当查询到的数据有二进制数据的话,就会用十六进制方式展示出来。

看看下面的例子吧:(建议在PC端或横版观看)

# 在 --skip-binary-as-hex 模式下
# 用CHAR()函数能把二进制转成ASCII字符
[[email protected]]> SELECT CHAR(77,121,83,81,'76');
+-------------------------+
| CHAR(77,121,83,81,'76') |
+-------------------------+
| MySQL                   |
+-------------------------+

# 在 --binary-as-hex(8.0.19后默认) 模式下
# 直接把二进制数据以十六进制输出了
...
Server characterset:    utf8mb4
...
UNIX socket:        /mysql/data01/mysql.sock
Binary data as:     Hexadecimal

[[email protected]]> SELECT CHAR(77,121,83,81,'76');
+--------------------------------------------------+
| CHAR(77,121,83,81,'76')                          |
+--------------------------------------------------+
| 0x4D7953514C                                     |
+--------------------------------------------------+


看起来是不是觉得怪怪的,很不适应。

新参数--binary-as-hex是MySQL 5.6.37版本开始引入的,由一位叫做Daniël van Eeden的哥们建议加入的

标签:binary,...,--,variables,hex,CHAR,mysql
From: https://blog.51cto.com/u_11571552/12120135

相关文章

  • MySQL variables:thread_handling
    在使用MySQL数据库时,我们经常会遇到多个客户端同时访问数据库的情况。为了处理并发请求,MySQL提供了thread_handling参数,用于控制线程的管理方式thread_handling参数的作用thread_handling参数用于控制MySQL如何处理客户端的连接请求。它可以影响数据库的性能、吞吐量以......
  • hexo部署报错:Deployer not found: git
    一、报错将hexo部署到Github时发生Deployernotfound:git报错二、报错原因及解决方法报错原因在初次部署hexo时没有安装hexo-deployer-git插件导致部署时发生Deployernotfound:git报错 解决方法1.执行cnpminstallhexo-deployer-git--save或npminstallhexo-d......
  • 树状数组(Binary Indexed Tree, BIT)
    树状数组(BinaryIndexedTree,BIT)树状数组(BinaryIndexedTree,BIT),也称为FenwickTree,是一种用于高效处理数组前缀和查询和单点更新的数据结构。它能够在(O(\logn))时间内完成单点更新和前缀和查询操作。基本概念前缀和:给定一个数组a,前缀和prefix_sum[i]表示a[0]+......
  • PAT甲级-1115 Counting Nodes in a Binary Search Tree
    题目 题目大意给定节点个数,以及每个节点的值,要求构造一棵二叉排序(搜索)树,并按照规定格式输出最后一层和倒数第二层的节点个数。思路二叉排序树的构造方法是递归,但思路类似于二分查找。逐个将n个节点插入到二叉排序树中,插入完成也就构造完成了。插入节点时,如果该节点值大于......
  • Bundle.main.url(forResource:withExtension:)和 Bundle.main.path(forResource:ofTyp
    这两种方式都可以用于获取应用程序包中的资源文件(如JSON文件),但它们在返回结果的类型和处理方式上有所不同:1.Bundle.main.url(forResource:withExtension:)返回类型:这个方法返回一个可选的URL(URL?)。使用场景:当你需要文件的路径作为URL时,使用这个方法更为方便,因为URL......
  • Hexo-GitHub部署魔改第一步-config
    Hexo-GitHub部署魔改第一步_config.yml1.config.yml#HexoConfiguration##Docs:https://hexo.io/docs/configuration.html##Source:https://github.com/hexojs/hexo/#Site#设置博客的标题title:YourBlogTitle#子标题,可选subtitle:'xxxxx'#博客的描述,可选......
  • -bash: ./blade: cannot execute binary file: Exec format error
    在执行程序时报错[[email protected]]#./bladeversion-bash:./blade:cannotexecutebinaryfile:Execformaterror判断系统架构是arch还是x86的,x86的包不能在aarch64执行,所以报错#查看系统架构类型arch#查看系统架构类型或uanme-a由于chaosblade不支持ARM平......
  • hexo安装后报错'hexo' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
    hexo问题之前利用hexo和gitee搭建了一个博客,但是最近gitee的gitpage停止服务了,便想着在github上搭建一个。在到安装hexo这一步的时候,一直报错'hexo'不是内部或外部命令,也不是可运行的程序或批处理文件。我的所有安装步骤和环境变量发现都没有错,反复配置后去找了一下官方文档:h......
  • 如何在 Cloudflare Page 上建立自己的 Hexo 博客
    本文首发于我的博客,部分图片和步骤来自在GitHubDesktop中向GitHub进行身份验证-GitHub文档0前置条件0.1安装Node.js打开nodejs.org,点击下载Node.js下载完毕后双击图标然后按Next点IacceptthetermsintheLicenseAgreement,再按Next然后一......
  • 用python写一段代码:读取一张图片中的所有颜色信息,并按照占比大小,从大到小依次列出颜色
    fromPILimportImagefromcollectionsimportCounterimportnumpyasnpdefsave_colors_to_file(image_path,output_file):#打开图片文件image=Image.open(image_path)image=image.convert('RGB')#将图片转换为numpy数组pixels=np.ar......