I have downloaded a wikipedia dump file and transferred its data to MySQL.

SELECT page_id, BINARY CONVERT(page_restrictions USING utf8)  from page

I used following query to convert page_restrictions field from blob to string.

I also tried to use following to read old_text value but it do not works.

SELECT BINARY CONVERT(old_text USING utf8) from text

What is wrong with it?

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    |                |
+-----------+------------------+------+-----+---------+----------------+
有帮助吗?

解决方案

You shouldn't have BINARY in that query. You should just need:

SELECT CONVERT(old_text USING utf8) from text

That's assuming the blob contains text encoded as utf_8.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top