Editing
排除 MySQL 技術疑難問題
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 錯誤 1070 (42000): 指定的鍵太長;最大鍵長為 767 位元組 === '''環境''': MySQL 5.6 '''根本原因''': "預設情況下,索引鍵前綴長度限制為 767 位元組。參見第 13.1.13 節,“CREATE INDEX 語句”。例如,在 TEXT 或 VARCHAR 列上,如果使用 utf8mb3 字元集,並且每個字元最多 3 位元組,您可能會在列前綴索引超過 255 個字元時達到此限制。當啟用 innodb_large_prefix 配置選項時,對於使用 DYNAMIC 或 COMPRESSED 行格式的 InnoDB 表,索引鍵前綴長度限制提高到 3072 位元組。" <ref>[https://dev.mysql.com/doc/refman/5.6/en/innodb-limits.html MySQL :: MySQL 5.6 參考手冊 :: 14.22 InnoDB 限制]</ref> '''解決方案'''<ref>[https://www.opencli.com/mysql/mysql-%E5%95%8F%E9%A1%8C-1071-42000-specified-key-was-too-long MySQL 問題: 1071 (42000): 指定的鍵太長]</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 – 全棧 Web 開發人員]</ref>: * 執行以下 SQL 查詢: <pre> SET GLOBAL innodb_file_format = Barracuda; SET GLOBAL innodb_file_format_max = Barracuda; </pre> * 修改 MySQL 配置文件 <pre> innodb_file_per_table = 1 innodb-file-format = BARRACUDA innodb-large-prefix = ON innodb_file_format_max = BARRACUDA </pre> * 重啟 MySQL 伺服器 * 執行以下 SQL 查詢: <pre> ALTER TABLE `table_name` ROW_FORMAT=COMPRESSED; </pre>
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information