小编典典

MySQL更改innodb_large_prefix

mysql

我只是在VM上设置了debian 8.3,并在本教程之后安装了xampp
。一切正常,直到我尝试创建一个新表:

create table testtable
(
  id int(10) not null auto_increment,
  firstname varchar(255) collate utf8mb4_german2_ci not null,
  lastname varchar(255) collate utf8mb4_german2_ci not null,
  primary key (id),
  unique key (lastname)
)engine = innodb default charset=utf8mb4, collate=utf8mb4_german2_ci

我得到了错误:#1709 - Index column size too large. The maximum column size is 767 bytes. 然后我发现它来自,prefix limitation它仅限于767Byte,Innodb可以通过在my.cnf文件中设置innodb_large_prefix来解决此问题。但是我找不到文件,它不在下面/etc/,也没有/etc/mysql/-folder,但是my.cnf我发现的唯一是在中/opt/lampp/etc/,但是,我将其添加innodb_large_prefix=1到文件并重新启动了lampp之后。我仍然得到同样的错误。我做错什么了?

编辑SELECT version()返回5.6.14,因此innodb_large_prefix应受支持。

edit2 :我知道我可以通过仅将部分密钥设置为索引来获得低于767Byte的方法来解决此问题。但是我想在这里知道如何正确配置mysql。


阅读 4739

收藏
2020-05-17

共1个答案

小编典典

在5.6.3和5.7.7之间(也就是说,如果您正在运行MySQL 5.6或MariaDB 10.0),有4个步骤:

  • SET GLOBAL innodb_file_format =梭子鱼;
  • SET GLOBAL innodb_file_per_table = ON;
  • ROW_FORMAT = DYNAMIC; -或压缩(在CREATE结尾)
  • innodb_large_prefix = 1

注意

SELECT * FROM information_schema.INNODB_SYS_TABLESPACES;

将提供file_format和row_format。其他一些I_S表提供了file_per_table的线索。

2020-05-17