Monday, 19 February 2024

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (in Mysql 5.6)

In Mysql 5.6, when you hit the limit. Set the following.
INNODB utf8 VARCHAR(255)
INNODB utf8mb4 VARCHAR(191)

Because: 767 bytes in MySQL version 5.6 (and prior versions), is the stated prefix limitation for InnoDB tables. It's 1,000 bytes long for MyISAM tables. This limit has been increased to 3072 bytes In MySQL version 5.7 (and upwards).

References:

- https://stackoverflow.com/questions/1814532/mysql-error-1071-specified-key-was-too-long-max-key-length-is-767-bytes

- https://viblo.asia/p/su-khac-nhau-giua-2-storage-engine-myisam-va-innodb-bJzKmgVPl9N

Thank you

No comments:

Post a Comment

Golang Advanced Interview Q&A