14,953
edits
| Line 377: | Line 377: | ||
** CHARACTER SETS (aka 字元集、字符集): {{kbd | key=utf8mb4}} | ** CHARACTER SETS (aka 字元集、字符集): {{kbd | key=utf8mb4}} | ||
** COLLATION (aka 定序、字元序): {{kbd | key=utf8mb4_unicode_ci}} | ** COLLATION (aka 定序、字元序): {{kbd | key=utf8mb4_unicode_ci}} | ||
=== ERROR 1070 (42000): Specified key was too long; max key length is 767 bytes === | |||
'''Envoronment''': MySQL 5.6 | |||
'''Root cause''': "By default, the index key prefix length limit is 767 bytes. See Section 13.1.13, “CREATE INDEX Statement”. For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a utf8mb3 character set and the maximum of 3 bytes for each character. When the innodb_large_prefix configuration option is enabled, the index key prefix length limit is raised to 3072 bytes for InnoDB tables that use the DYNAMIC or COMPRESSED row format." <ref>[https://dev.mysql.com/doc/refman/5.6/en/innodb-limits.html MySQL :: MySQL 5.6 Reference Manual :: 14.22 InnoDB Limits]</ref> | |||
'''Solution'''<ref>[https://www.opencli.com/mysql/mysql-%E5%95%8F%E9%A1%8C-1071-42000-specified-key-was-too-long MySQL 問題: 1071 (42000): Specified key was too long]</ref><ref>[https://terrytongcc.com/%E5%A6%82%E4%BD%95%E8%A7%A3%E6%B1%BAmysql%E5%87%BA%E7%8F%BEerror-1118-row-size-too-large-8126%E5%95%8F%E9%A1%8C/ 如何解決MySQL出現Error 1118: row size too large (> 8126)問題 | Terry Tong – Full Stack Web Developer]</ref>: | |||
* execute SQL query as the following: | |||
<pre> | |||
SET GLOBAL innodb_file_format = Barracuda; | |||
SET GLOBAL innodb_file_format_max = Barracuda; | |||
</pre> | |||
* modify the MySQL configuration file | |||
<pre> | |||
innodb_file_per_table = 1 | |||
innodb-file-format = BARRACUDA | |||
innodb-large-prefix = ON | |||
innodb_file_format_max = BARRACUDA | |||
</pre> | |||
* restart the MySQL server | |||
* execute SQL query as the following: | |||
<pre> | |||
ALTER TABLE `table_name` ROW_FORMAT=COMPRESSED; | |||
</pre> | |||
== Connection and Network Errors == | == Connection and Network Errors == | ||