在 phpMyAdmin 中查看 Blob 的内容

发布于 2024-08-20 18:14:15 字数 290 浏览 4 评论 0原文

很抱歉新手问题,但是圆圈按钮是什么意思,以及如何查看 blob 的内容? 替代文本
(来源:rigel222.com

Sorry for the Noob Question, but what does the circled button mean, and how can I view the content of a blob?
alt text
(source: rigel222.com)

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

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

发布评论

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

评论(9

平生欢 2024-08-27 18:14:15

早期版本的 phpmyadmin 有一个名为

$cfg['ShowBlob']              = TRUE;

That 的设置,允许您在浏览器中查看 blob 的内容。您应该注意,如果您将二进制文件存储在 blob 中,这会导致混乱,因为您会在浏览器窗口中看到无尽的 gobblygok。有些人(像我一样)决定他们的应用程序需要使用 BLOB 类型来存储文本(当时似乎是一个不错的决定,而且我记得我在做出这个决定时进行了一些思考)。然而 phpmyadmin 决定通过弃用此配置设置来阻止这种情况。这是可以理解的,因为这样做可能会引起大量的支持请求。显然,我们的想法是让人们转向 TEXT 字段类型。

愉快地显示 blob 内容已移至用户界面而不是配置中。

浏览时查看 blob 内容的最简单方法是单击链接:

+ 选项

幸运的是,您的屏幕截图已经在顶部的顶部显示了 + 选项图像。

这将显示一个表单,允许您显示 blob(和二进制文件)。单击该按钮,它会将其添加到您选择的会话中,确保您从那时起就可以看到内容。

您还可以使用打印视图获得相同的结果:

打印视图(带全文)

位于页面底部。

遗憾的是,如果您总是想显示斑点,这两种技术都没有帮助,因为它似乎经常重置。 添加行来解决此问题

$_GET['display_blob'] = true;

您可以通过在 sql.php 文件的开头 。我认为可能有更好的方法来做到这一点,我希望其他人可以提出它......

(注意:正如罗德里戈指出的那样,您可以通过附加 &display_blob=true 在 URL 上)

您关于“选择文件”按钮的具体问题很简单。 Blob 的大部分用途是在数据库中存储数字文件。此按钮允许您将新文件上传到数据库中。如果您选择一个文件并单击“执行”,它会尝试将该文件的内容填充到 blob 列中。

请注意,简单地显示 blob 的内容可能不是其他用户想要的。当我在使用此选项显示 blob 之前查看“blob 摘要”时,我看到 blob 大小最大为 55 字节。您的示例具有更大的值,因为看起来您正在存储非常小的文本文件,我认为这意味着文本段落。如果大小大于 10 千字节,则它可能是一个仅显示 gooblegok 的二进制文件。

如果您想智能地下载二进制文件(而不是将它们显示为文本),我认为您需要了解 phpmyadmin 所谓的 blobstreaming。

earlier versions of phpmyadmin had a setting called

$cfg['ShowBlob']              = TRUE;

That would allow you to view the contents of blobs in the browser. You should note that this would cause chaos if you were storing binary files in blobs, since you would see endless gobblygok in the browser window. There are some people (like me) who decided that their application needed to use BLOB types to store text (seemed like a good decision at the time, and as I recall there was some thinking on my part that went into the decision). However phpmyadmin decided to discourage this by deprecating this config setting. Understandable since doing this might cause quite a support request. Apparently the thinking was to move people over the TEXT field types.

Happily displaying the contents of blobs has been moved into the user interface rather than the configuration.

The simplest way to see the contents of blobs when you are browsing is to click the link:

+ Options

Happily your screenshot already shows the + Options in the top part of the top image.

Which will display a form that will allow you to display blobs (and binaries). Click that and it will add it to your choice to the session, ensuring that you see the contents from then on.

You can also get the same result using print view:

Print view (with full texts)

Which lives at the bottom of the page.

Sadly both of these techniques are not helpful if you always want to display the blob, since it appears to reset frequently. You can fix this by adding the line

$_GET['display_blob'] = true;

At the beginning of the sql.php file. I think there might be a better way to do this, and I hope someone else might bring it up...

(note: as Rodrigo pointed out you can manually achieve this effect by appending &display_blob=true on the URL)

Your specific question about the "Choose File" button is simple. Most of the uses of blobs are for storing digital files in the database. This button allows you to upload a new file into the database. If you select a file and click "go" it will try to stuff the contents of that file into the blob column for you.

Just to note, simply displaying the contents of the blob is probably not what other users want. When I look at the "blob summary" before I use this option to display the blobs I see blob sizes of 55 bytes max. Your example has bigger values, because it looks like you are storing very small text files, which I assume means paragraphs of text. If the size is bigger then 10's of kilo-bytes it is probably a binary file that will just display gooblegok.

If you want to download binary files intelligently (rather than displaying them as text) I think you need to look into what phpmyadmin calls blobstreaming.

调妓 2024-08-27 18:14:15

&display_blob=true 放在网址末尾。

Put &display_blob=true on the end of your URL.

爱你不解释 2024-08-27 18:14:15

对于新访问者,查看 BLOB 列的另一种方法是 QUOTE() 函数。为了方便起见,您可以从中创建一个视图。 (视图的行为类似于表,但它实际上是一种保存的查询):

CREATE VIEW log_text AS SELECT BlobID, FileName, CAST(QUOTE(Content) AS CHAR) FROM log;

您必须将结果转换为 CHAR,因为 QUOTE(binary) 仍然是二进制的。这可能会导致一些混乱(正如 @ftrotter 所说),因为 QUOTE 只翻译控制字符,而不是超 ASCII 字符。

输入图片这里的描述

为了减少混乱,使用 十六进制()

For new visitors, another way to view BLOB columns is the QUOTE() function. You can create a view out of it for convenience. (A view behaves like a table but it's really a kind of saved query):

CREATE VIEW log_text AS SELECT BlobID, FileName, CAST(QUOTE(Content) AS CHAR) FROM log;

You'll have to CAST the result as CHAR because QUOTE(binary) is still binary. This may cause some chaos (as @ftrotter puts it) because QUOTE only translates control characters, not supra-ASCII characters.

enter image description here

For less chaos use HEX().

╰沐子 2024-08-27 18:14:15

我认为最好的解决方案是将这一行:更改

$cfg['Servers'][$i]['extension'] = 'mysql';

为:

$cfg['Servers'][$i]['extension'] = 'mysqli';

如果您有可用的 mysqli 扩展,请使用它。它更安全,更优化,并且默认情况下可以更好地处理 utf-8 的 BLOB 类型。您的 [BLOB] 条目应该开始显示为其值,而无需添加任何其他特殊配置选项。

I think the best solution is to change this line:

$cfg['Servers'][$i]['extension'] = 'mysql';

to this:

$cfg['Servers'][$i]['extension'] = 'mysqli';

If you have the mysqli extension available, use it. It is more secure, a bit more optimized, and it handles the BLOB type of utf-8 better by default. Your [BLOB] entries should start showing up as their values without having to add in any other special configuration options.

汐鸠 2024-08-27 18:14:15

新版本的 PHPMyAdmin 似乎需要稍微不同的解决方案

$cfg['ProtectBinary'] = FALSE;

将其放在文件的末尾 /etc/phpmyadmin/config.inc.php

或者使用这个衬垫

echo "\$cfg['ProtectBinary'] = FALSE;" | sudo tee -a /etc/phpmyadmin/config.inc.php

这对我在 PHPMyAdmin 版本 3.4 上有用.10.1deb1

New versions of PHPMyAdmin seem to require a slightly different solution

$cfg['ProtectBinary'] = FALSE;

Place this at the end of the file /etc/phpmyadmin/config.inc.php

Or by using this one liner

echo "\$cfg['ProtectBinary'] = FALSE;" | sudo tee -a /etc/phpmyadmin/config.inc.php

This worked for me on PHPMyAdmin version 3.4.10.1deb1

小伙你站住 2024-08-27 18:14:15

phpMyAdmin 中已经有一个处理程序来显示 blob 数据
为此,只需在网址末尾添加“&display_blob=true”即可。
将 url 更改如下:

*****phpmyadmin/sql.php?db=database_name&table=table_name

*****phpmyadmin/sql.php?db=database_name&table=table_name&display_blob=true

There is already a handler in phpMyAdmin to show blob data
For this just add "&display_blob=true" at the end of the url.
Change url like below:

*****phpmyadmin/sql.php?db=database_name&table=table_name

to

*****phpmyadmin/sql.php?db=database_name&table=table_name&display_blob=true

素手挽清风 2024-08-27 18:14:15

“选择文件”对话框允许您在工作站上选择一个文件并将其上传到该行的 blob 列中。

如果您的 BLOB 包含 JPEG 或 PNG 图像,则您实际上可以在浏览时查看它们的缩略图,并在单击缩略图时显示完整图像。请参阅https://phpmyadmin.readthedocs.org/en/latest/transformations.html

The "Choose file" dialog permits you to pick a file on your workstation and upload it inside the blob column for this row.

If your BLOB contains JPEG or PNG images, you can actually view their thumbnails when browsing, with the full image being displayed when you click on the thumbnail. See https://phpmyadmin.readthedocs.org/en/latest/transformations.html.

我也只是我 2024-08-27 18:14:15

将链接另存为txt文件

您可以右键单击phpMyAdmin并将链接另存为txt文件扩展名来查看blob 文本文件类型

Save Link As txt file

You can right click on phpMyAdmin and save link as txt file extension to view the blob text file type

汐鸠 2024-08-27 18:14:15

我在 config.inc.php 中添加了这个,这对我帮助很大

# Show BLOB data on table browse pages.  Hack to hardcode all requests.
$_REQUEST['display_blob'] = true;

I've added additional this to me to config.inc.php that helped me out so much

# Show BLOB data on table browse pages.  Hack to hardcode all requests.
$_REQUEST['display_blob'] = true;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文