简体   繁体   English

当行大小太大时,如何转换MYSQL UTF-8?

[英]How to convert MYSQL UTF-8 when a row size is too large?

I'm on a MYSQL database attempting to alter my table encoded in latin1 to UTF-8. 我在一个MYSQL数据库上,试图将以latin1编码的表更改为UTF-8。 The tables name is Journalist that has 12 columns listed as varchar with max length of 3000. This is the sql i'm running. 表名是Journalist,有12列列为varchar,最大长度为3000。这是我正在运行的sql。

ALTER TABLE `journalist` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

The error I'm receiving 我收到的错误

Row size too large. 行大小太大。 The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. 不包括BLOB在内的已使用表类型的最大行大小为65535。这包括存储开销,请查阅手册。 You have to change some columns to TEXT or BLOBs 您必须将某些列更改为TEXT或BLOB

Do I have to alter the size of the table before I run this conversion query? 在运行此转换查询之前,是否需要更改表的大小? and/or how I might accomplish this encoding alteration otherwise? 和/或否则我将如何完成此编码更改?

I did what @Wrikken suggested. 我按照@Wrikken的建议做了。 I deleted my table and lowered varchar's max_length attributes to 1500 from 3000. I then ran this SQL on my new empty table 我删除了表并将varchar的max_length属性从3000降低到1500。然后在新的空表上运行了此SQL

ALTER TABLE `table_name` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

from here, I repopulated it with my backup table, using a script. 从这里,我使用脚本用备份表重新填充了它。

To answer the question: Lower varchar max_length limits Or change varchar fields to LONGTEXT, or BLOBS 要回答这个问题:降低varchar max_length限制或将varchar字段更改为LONGTEXT或BLOBS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM