MySQL 5.7 到 5.6,出現 Index column size too large. The maximum column size is 767 bytes
MySQL 5.7建表語句:
CREATE TABLE `4dfca143de64f9b67a59f2d4e8dde0e2_51941` (
`姓名` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL,
`年齡` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL,
`住址` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`姓名`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
在MySQL 5.6執行報錯如下:
錯誤程式碼: 1709
Index column size too large. The maximum column size is 767 bytes.
解決辦法:
InnoDB Row Format Overview
Row Format | Compact Storage Characteristics | Enhanced Variable-Length Column Storage | Large Index Key Prefix Support | Compression Support | Supported Tablespace Types | Required File Format |
---|---|---|---|---|---|---|
REDUNDANT | No | No | No | No | system, file-per-table | Antelope or Barracuda |
COMPACT | Yes | No | No | No | system, file-per-table | Antelope or Barracuda |
DYNAMIC | Yes | Yes | Yes | No | file-per-table | Barracuda |
COMPRESSED | Yes | Yes | Yes | Yes | file-per-table | Barracuda |
可以看出,支援innodb_large_prefix的row format只有dynamic 和compressed,而且它們需要的file format必須為Barracuda。
於是,檢視MySQL 5.7的預設引數配置:
mysql> SHOW VARIABLES LIKE '%innodb_version%'\G
*************************** 1. row ***************************
Variable_name: innodb_version
Value: 5.7.20
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'innodb_large_prefix'\G
*************************** 1. row ***************************
Variable_name: innodb_large_prefix
Value: ON
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'innodb_file_format'\G
*************************** 1. row ***************************
Variable_name: innodb_file_format
Value: Barracuda
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'innodb_file_per_table'\G
*************************** 1. row ***************************
Variable_name: innodb_file_per_table
Value: ON
1 row in set (0.01 sec)
檢視MySQL 5.6的預設引數配置:
mysql> SHOW VARIABLES LIKE '%innodb_version%'\G
*************************** 1. row ***************************
Variable_name: innodb_version
Value: 5.6.24
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'innodb_large_prefix'\G
*************************** 1. row ***************************
Variable_name: innodb_large_prefix
Value: OFF
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'innodb_file_format'\G
*************************** 1. row ***************************
Variable_name: innodb_file_format
Value: Antelope
1 row in set (0.01 sec)
mysql> SHOW VARIABLES LIKE 'innodb_file_per_table'\G
*************************** 1. row ***************************
Variable_name: innodb_file_per_table
Value: ON
1 row in set (0.00 sec)
從以上比較可以看出5.7和5.6之間引數的預設配置區別,然後我們將5.6的引數配置成和5.7一致
mysql> SET GLOBAL innodb_large_prefix=ON;
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL innodb_file_format=Barracuda;
Query OK, 0 rows affected (0.00 sec)
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> CREATE TABLE `4dfca143de64f9b67a59f2d4e8dde0e2_519411` (
-> `姓名` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL,
-> `年齡` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL,
-> `住址` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL,
-> PRIMARY KEY (`姓名`)
-> ) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.02 sec)
可以看到修改引數以及加上row_format=dynamic後表建立成功了。
相關文章
- Index column size too large. The maximum column size is 767 bytes.Index
- mysql5.7 資料匯入5.6 Index column size too large. The maximum column size is 767 bytes.MySqlIndex
- 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- [Err] 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- MySQL建立表失敗:Index column size too large. The maximum column size is 767 bytesMySqlIndex
- mysql specified key was too long與Index column size too large. The maximum column size is 767 bytes.MySqlIndex
- MySQL資料庫index column size too large. the maximum column size is 767 bytes問題解決MySql資料庫Index
- mysql Index column size too large 超過767錯誤解決方案(轉)MySqlIndex
- #1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs
- data too long for column
- ORA-12899: value too large for column ORG_NAME (actual: 145, maximum: 128)
- Mysql 報Row size too large 65535解決方法MySql
- Bug 31625618 DML Over a LOB Column ORA-3137 [3146]When the Bind Size is > 256k
- PHP Fatal error: Allowed memory size of 1610612736 bytesPHPError
- zblog顯示Allowed memory size of 6553652 bytes exhauste
- Row size too large (> 8126)解決辦法
- Mysql Key Buffer SizeMySql
- 偶遇ERROR 1071 (42000): Specified key was too long; max key length is 767 bytesError
- 解決 Specified key was too long ... 767 bytes 的本質問題
- java.lang.IndexOutOfBoundsException: Index: 0, Size: 0JavaIndexException
- Unhandled rejection RangeError: Maximum call stack size exceededill install loadIdealTreeErrorIdea
- ORA-01144: File size (4224000 blocks) exceeds maximum of 4194303BloC
- ProTable 報錯Uncaught RangeError: Maximum call stack size exceededError
- Vue專案中出現:Maximum call stack size exceeded(堆疊溢位)Vue
- [20180608]Wrong Results with IOT, Added Column and Secondary Index.txtIndex
- js中Uncaught RangeError: Maximum call stack size exceeded錯誤JSError
- [20180609]Wrong Results with IOT, Added Column and Secondary Index2.txtIndex
- MySQL:5.6 升級 5.7MySql
- 修改SharePoint上傳檔案大小限制(Changing Maximum Upload Size)
- MySQL 5.7 建立使用者報錯 ERROR 1805 (HY000): Column count of mysql.user is wrongMySqlError
- 關於錯誤訊息 RangeError - Maximum call stack size exceeded at XXXError
- mysql Unknown column ‘‘ in ‘field list‘解決方案MySql
- OGG-01163 Bad column length (32) specified for column in table
- MySQL 5.7從庫報錯exceeds of slave_pending_jobs_size_max. Error_code: 1864MySqlError
- iis 0x80070032 Cannot read configuration file because it exceeds the maximum file size
- MySQL8.0 新特性:Partial Update of LOB ColumnMySql
- 帝國cms網站Fatal error: Allowed memory size of … bytes exhausted怎麼辦?網站Error
- MySQL innodb_buffer_pool_size 變數MySql變數