14,954
edits
| Line 156: | Line 156: | ||
* 檢查 'MY_DATABASE_p' 資料庫是否存在 | * 檢查 'MY_DATABASE_p' 資料庫是否存在 | ||
* 如果您在使用控制台時希望連接到 'MY_DATABASE' 資料庫,請檢查資料庫名稱後是否沒有 {{kbd | key=TAB}} 字元。 | * 如果您在使用控制台時希望連接到 'MY_DATABASE' 資料庫,請檢查資料庫名稱後是否沒有 {{kbd | key=TAB}} 字元。 | ||
=== 錯誤 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> | |||
== 資源和環境錯誤 == | == 資源和環境錯誤 == | ||