1071 - 指定的键太长;最大密钥长度为 1000 字节 [英] 1071 - Specified key was too long; max key length is 1000 bytes
问题描述
导入 Sqlbackup 时出现以下错误:
I get following error when I Import the Sqlbackup i have:
SQL-Befehl:
SQL-Befehl:
CREATE TABLE jos_hikashop_zone_link (
zone_parent_namekey VARCHAR(255) NOT NULL,
zone_child_namekey VARCHAR(255) NOT NULL,
PRIMARY KEY (zone_parent_namekey, zone_child_namekey)
)
ENGINE = MYISAM
AVG_ROW_LENGTH = 49
CHARACTER SET utf8
COLLATE utf8_general_ci
MySQL meldet: Dokumentation
1071 - 指定的键太长;最大密钥长度为 1000 字节
我已经尝试过在导入文件之前设置 GLOBAL storage_engine='InnoDb'".
1071 - Specified key was too long; max key length is 1000 bytes
I have tried to "set GLOBAL storage_engine='InnoDb'" before I Import the file.
我无法获得新的 SQLImportfile.
I can`t get a new SQLImportfile.
我在本地机器上使用 XAMPP.
I am using XAMPP on a local machine.
推荐答案
因为您的主键是两个 UTF8 VARCHAR(255) 列上的多列主键,所以索引大小是两列的大小加在一起.
Because your primary key is a multi-column primary key on both UTF8 VARCHAR(255) columns, the index size is the size of both columns, added together.
UTF8 列上的索引会自动分配所有可能的空间,其中每个字符最多可占用 3 个字节.因此,您的索引大小为 255 个字符 * 3 个字节 * 2 列 = 1530 个字节.
Indexes on UTF8 columns automatically allocate all possible space, where each character could take up to 3 bytes. Therefore, your index size is 255 characters * 3 bytes * 2 columns = 1530 bytes.
MyISAM 的索引限制为 1000 字节.InnoDB 的限制甚至更小(767 字节),除非您使用的是 MySQL 5.7.7+,在这种情况下,默认限制为 3072 字节.
MyISAM has a limit of 1000 bytes for indexes. InnoDB has an even smaller limit (767 bytes) unless you're on MySQL 5.7.7+, in which case the limit is 3072 bytes by default.
尝试减小索引大小.通常,索引大小越小,搜索性能就越好.
Try to reduce your index size. Typically, the smaller your index size, the better your seek performance will be.
这篇关于1071 - 指定的键太长;最大密钥长度为 1000 字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!