我已经下载了一个维基百科转储文件并将其数据传输到 MySQL。
SELECT page_id, BINARY CONVERT(page_restrictions USING utf8) from page
我使用以下查询将 page_restrictions
字段从 blob 转换为字符串。
我还尝试使用以下方法来读取 old_text
值,但它不起作用。
SELECT BINARY CONVERT(old_text USING utf8) from text
这有什么问题吗?
mysql> describe text;
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| old_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| old_text | mediumblob | NO | | NULL | |
| old_flags | tinyblob | NO | | NULL | |
+-----------+------------------+------+-----+---------+----------------+
最佳答案
该查询中不应包含 BINARY
。你应该只需要:
SELECT CONVERT(old_text USING utf8) from text
假设 blob 包含编码为 utf_8 的文本。
关于mysql - 从 Wikipedia 转储文件中重新编辑 BLOB 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17512870/