문제

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