Mike Pearson
Mike Pearson

Reputation: 79

MySQL CHARACTER SET utf8mb4 VARCHAR length

Spent the last few days looking for any gotcha's converting from the various supported MySQL charsets to using utf8mb4. It seems as though the largest problem most people face is that the 4-byte characters mean that the max length for InnoDB indexes, for column types like VARCHAR, are restricted to 191 rather than 255. It also mentions that the column sizes for a non-indexed VARCHAR column should be 191 rather than 255.

After testing, I see that you do receive an error when converting a column to 255 if it is indexed, but do not when it is not indexed. Is there any reason to reduce the length of a non-indexed VARCHAR column from 255 to 191 if there is no plan to index it in the future?

Upvotes: 1

Views: 6671

Answers (1)

Rick James
Rick James

Reputation: 142518

Read this for a discussion of the 767 limit and various workarounds. Note that one workaround is to update to Version 5.7, which increases the limit past 3KB.

(I am changing your title since the collation is irrelevant to the Question.)

Upvotes: 4

Related Questions