在 mysql 导出中将 blob 转换为文本
我有一些 blob 数据,例如:
0x3333332c2044e963617269652c20356520e9746167650d0a53742d4c617572656e7420285175e9626563292048344e20334d390d0a
我想将其转换为文本,因为新数据库有文本字段而不是 blob,现在它对一些重音字符造成了麻烦。
某处是否有某种 blob 到字符串转换器?
多谢!
I'd have some blob data such as:
0x3333332c2044e963617269652c20356520e9746167650d0a53742d4c617572656e7420285175e9626563292048344e20334d390d0a
that I'd like to convert to text because the new database has text field instead of blobs and now it makes trouble with some accentuated characters.
Is there somekind of blob to string converter somewhere?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试:
Try:
这取决于斑点是什么。例如,我处理过一些可以表示为基本 XML 文件的 blob。这些相对容易转换。但是,我处理了其他作为图像文件的 blob。如果您尝试将它们表示为文本,您将丢失数据。
你的斑点里有什么?
It depends on what the blob is. For example, I've dealt with some blobs that could be represented as basic XML files. Those would have been relatively easy to convert. However, I dealt with other blobs that were image files. If you tried to represent them as text you'd lose data.
What are in your blobs?
但是,如果数据包含简单的字节流(即非结构化数据、文件、音频、视频等),并且您需要将它们表示为纯 ASCII,则可以将其更改为 Base64 字符串。
However if the data contains simple byte stream (that is, unstructured data, files, audio, video, whatever) and you need to represent them as pure ASCII you could change into a Base64 string.
使用导出创建新数据库,完成后在表上创建文本列,使用
CONVERT
删除旧列进行更新,如果需要,可以重命名旧列。Create your new database with your export, once done create your text column on the table, update that using a
CONVERT
drop the old column, renaming the old one if required.如果使用 phpmyadmin,请勾选导出页面底部的“以十六进制表示法转储二进制列(例如,“abc”变为 0x616263)”框。
If using phpmyadmin, tick the box that says "Dump binary columns in hexadecimal notation (for example, "abc" becomes 0x616263)" at the bottom of the export page.