如何在 MySQL Workbench 中直接查看 blob

发布于 2024-10-06 00:08:27 字数 296 浏览 0 评论 0原文

我正在使用 MySQL Workbench CE 5.2.30 CE/Rev 6790 。当执行以下语句时:

SELECT OLD_PASSWORD("test")

我只得到一个漂亮的 BLOB 图标,我需要左键单击以选择单元格,右键单击并选择“在查看器中打开值”并选择“文本”选项卡。

使用与 phpMyAdmin 相同的方法,我可以直接返回 OLD_PASSWORD 调用的值。这只是一个例子,但是有没有办法直接在输出中看到这样的结果呢?

I'm using MySQL Workbench CE 5.2.30 CE / Rev 6790 . When execute the following statement:

SELECT OLD_PASSWORD("test")

I only get back a nice BLOB icon, I need to left-click to select the cell, right-click and choose "Open Value in viewer" and select the "Text" tab.

Using the same with phpMyAdmin, I get directly back the value of the OLD_PASSWORD call. It's just an example, but is there a way to directly see such results in the output?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

最佳男配角 2024-10-13 00:08:27

简而言之:

在 MySQL Workbench 6.0+

  1. 转到 编辑 > 首选项
  2. 选择SQL 编辑器
  3. SQL 执行下,选中将 BINARY/VARBINARY 视为非二进制字符串
  4. 重新启动 MySQL Workbench(您不会提示或通知此要求)。

在旧版本的 MySQL Workbench 中

  1. 转到编辑 > 首选项
  2. 选择SQL 查询
  3. 查询结果下,选中将 BINARY/VARBINARY 视为非二进制字符串
  4. 不强制重新启动MySQL Workbench(不会提示或通知您此要求)。*

通过此设置,您将能够连接字段而无需获取 blob。

我认为这适用于版本 5.2.22 及更高版本,并且是 此 MySQL bug。

免责声明:我不知道此设置的缺点是什么 - 也许当您选择 BINARY/VARBINARY 值时,您会将其视为纯文本,这可能会产生误导,并且/或者如果它们足够大的话可能会影响性能?

In short:

In MySQL Workbench 6.0+

  1. Go to Edit > Preferences
  2. Choose SQL Editor
  3. Under SQL Execution, check Treat BINARY/VARBINARY as nonbinary character string
  4. Restart MySQL Workbench (you will not be prompted or informed of this requirement).

In older versions of MySQL Workbench

  1. Go to Edit > Preferences
  2. Choose SQL Queries
  3. Under Query Results, check Treat BINARY/VARBINARY as nonbinary character string
  4. It's not mandatory to restart MySQL Workbench (you will not be prompted or informed of this requirement).*

With this setting you will be able to concatenate fields without getting blobs.

I think this applies to versions 5.2.22 and later and is the result of this MySQL bug.

Disclaimer: I don't know what the downside of this setting is - maybe when you are selecting BINARY/VARBINARY values you will see it as plain text which may be misleading and/or maybe it will hinder performance if they are large enough?

风吹雪碎 2024-10-13 00:08:27

我不确定这是否回答了问题,但如果您右键单击字段中的“blob”图标(查看表格时),则会出现“在编辑器中打开值”的选项。其中一个选项卡可让您查看该 blob。这是在版本中。 5.2.34

I'm not sure if this answers the question but if if you right click on the "blob" icon in the field (when viewing the table) there is an option to "Open Value in Editor". One of the tabs lets you view the blob. This is in ver. 5.2.34

要走干脆点 2024-10-13 00:08:27

执行三个步骤:

  1. 转到“WorkBench Preferences”-->选择“查询结果”下的“SQL编辑器”:选中“将BINARY/VARBINARY视为非二进制字符串”

  2. 重新启动 MySQL WorkBench。

  3. 现在选择SELECT SUBSTRING(,1,2500) FROM;

Perform three steps:

  1. Go to "WorkBench Preferences" --> Choose "SQL Editor" Under "Query Results": check "Treat BINARY/VARBINARY as nonbinary character string"

  2. Restart MySQL WorkBench.

  3. Now select SELECT SUBSTRING(<BLOB_COLUMN_NAME>,1,2500) FROM <Table_name>;

内心旳酸楚 2024-10-13 00:08:27
select CONVERT((column_name) USING utf8) FROM table;

就我而言,工作台不起作用。所以我使用上面的解决方案将 blob 数据显示为文本。

select CONVERT((column_name) USING utf8) FROM table;

In my case, Workbench does not work. so i used the above solution to show blob data as text.

旧城空念 2024-10-13 00:08:27

转换有效,但很痛苦,所以我建议使用 spioter 的方法,除非您使用大量真正的 blob 数据。

SELECT CAST(OLD_PASSWORD("test") AS CHAR)

你还可以转换为其他类型,甚至限制大小,但大多数时候我只使用 CHAR:
http://dev.mysql.com/doc/refman /5.5/en/cast-functions.html#function_cast

casting works, but it is a pain, so I would recommend using spioter's method unless you are using a lot of truly blob data.

SELECT CAST(OLD_PASSWORD("test") AS CHAR)

You can also cast as other types, and even restrict the size, but most of the time I just use CHAR:
http://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_cast

雨后咖啡店 2024-10-13 00:08:27

恐怕这似乎不可能,它被列为工作台中的错误:
http://bugs.mysql.com/bug.php?id=50692
不过这会非常有用!

Doesn't seem to be possible I'm afraid, its listed as a bug in workbench:
http://bugs.mysql.com/bug.php?id=50692
It would be very useful though!

情绪少女 2024-10-13 00:08:27

有同样的问题,根据MySQL文档,你可以选择 BLOB 的子字符串:

SELECT id, SUBSTRING(comment,1,2000) FROM t

HTH、glissi

had the same problem, according to the MySQL documentation, you can select a Substring of a BLOB:

SELECT id, SUBSTRING(comment,1,2000) FROM t

HTH, glissi

椵侞 2024-10-13 00:08:27

我将其他一些帖子拼凑在一起,因为工作台“首选项”修复对我不起作用。 (世界银行 6.3)

SELECT CAST(`column` AS CHAR(10000) CHARACTER SET utf8) FROM `table`;

I pieced a few of the other posts together, as the workbench 'preferences' fix did not work for me. (WB 6.3)

SELECT CAST(`column` AS CHAR(10000) CHARACTER SET utf8) FROM `table`;
み格子的夏天 2024-10-13 00:08:27

工作台6.3
遵循高分答案,然后使用 UNCOMPRESS()

(简而言之:
1. 转到编辑>偏好设置
2.选择SQL编辑器
3. 在“SQL 执行”下,选中“将 BINARY/VARBINARY 视为非二进制字符串”
4. 重新启动 MySQL Workbench(不会提示或通知您此要求)。)

然后

SELECT SUBSTRING(UNCOMPRESS(<COLUMN_NAME>),1,2500) FROM <Table_name>;

或者

SELECT CAST(UNCOMPRESS(<COLUMN_NAME>) AS CHAR) FROM <Table_name>;

如果您只是输入 UNCOMPRESS() 您可以右键单击 blob 并单击“Open Value in编辑”。

Work bench 6.3
Follow High scoring answer then use UNCOMPRESS()

(In short:
1. Go to Edit > Preferences
2. Choose SQL Editor
3. Under SQL Execution, check Treat BINARY/VARBINARY as nonbinary character string
4. Restart MySQL Workbench (you will not be prompted or informed of this requirement).)

Then

SELECT SUBSTRING(UNCOMPRESS(<COLUMN_NAME>),1,2500) FROM <Table_name>;

or

SELECT CAST(UNCOMPRESS(<COLUMN_NAME>) AS CHAR) FROM <Table_name>;

If you just put UNCOMPRESS(<COLUMN_NAME>) you can right click blob and click "Open Value in Editor".

风苍溪 2024-10-13 00:08:27

您可以做的事情很少,

SELECT GROUP_CONCAT(CAST(name AS CHAR))
FROM product
WHERE  id   IN (12345,12346,12347)

如果您想按查询排序,

SELECT GROUP_CONCAT(name ORDER BY name))
FROM product
WHERE id   IN (12345,12346,12347)

您也可以按强制转换排序,如下所示,如本博客中所述

http://www.kdecom.com/mysql-group-concat-blob-bug-solved/

there is few things that you can do

SELECT GROUP_CONCAT(CAST(name AS CHAR))
FROM product
WHERE  id   IN (12345,12346,12347)

If you want to order by the query you can order by cast as well like below

SELECT GROUP_CONCAT(name ORDER BY name))
FROM product
WHERE id   IN (12345,12346,12347)

as it says on this blog

http://www.kdecom.com/mysql-group-concat-blob-bug-solved/

自由范儿 2024-10-13 00:08:27

注意:如果 BLOB 是任意字节序列,则前面的答案并不是特别有用。例如 BINARY(16) 存储 128 位 GUID 或 md5 校验和。

在这种情况下,目前没有编辑器首选项——尽管我现在已经提交了功能请求 - 请参阅该请求以获取更详细的解释。

[直到/除非实现该功能请求],解决方案是查询中的 HEX 函数:SELECT HEX(mybinarycolumn) FROM mytable


另一种方法是使用 phpMyAdmin 而不是 MySQL Workbench - 默认显示十六进制。

NOTE: The previous answers here aren't particularly useful if the BLOB is an arbitrary sequence of bytes; e.g. BINARY(16) to store 128-bit GUID or md5 checksum.

In that case, there currently is no editor preference -- though I have submitted a feature request now -- see that request for more detailed explanation.

[Until/unless that feature request is implemented], the solution is HEX function in a query: SELECT HEX(mybinarycolumn) FROM mytable.


An alternative is to use phpMyAdmin instead of MySQL Workbench - there hex is shown by default.

裂开嘴轻声笑有多痛 2024-10-13 00:08:27

你可以尝试

SELECT *, HEX(<BLOB_COLUMN>) as blob_vectors
FROM <BLOB_COLUMN> 
LIMIT 100; 

You can try

SELECT *, HEX(<BLOB_COLUMN>) as blob_vectors
FROM <BLOB_COLUMN> 
LIMIT 100; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文