gpt4 book ai didi

mysql 更改 innodb_large_prefix

转载 作者:可可西里 更新时间:2023-11-01 06:53:29 35 4
gpt4 key购买 nike

我只是在虚拟机上安装了 debian 8.3 并在此之后安装了 xampp Tutorial .一切正常,直到我尝试创建一个新表:

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 limitationInnodb 中限制为 767Byte我可以通过在 my.cnf 文件中设置 innodb_large_prefix 来解决这个问题。但是我找不到文件,它不在 /etc/ 下并且没有 /etc/mysql/ -文件夹,唯一my.cnf我发现在 /opt/lampp/etc/ , 但是,在我添加了 innodb_large_prefix=1 之后到文件并重新启动lampp。我仍然遇到同样的错误。我做错了什么?

编辑:SELECT version()返回 5.6.14 , 所以 innodb_large_prefix应该支持。

edit2:我知道我可以通过仅将部分 key 设置为索引来解决此问题,使其小于 767 字节。但我想在这里知道如何正确配置 mysql。

最佳答案

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

  • SET GLOBAL innodb_file_format=Barracuda;
  • 设置全局 innodb_file_per_table=ON;
  • ROW_FORMAT=动态; -- 或 COMPRESSED(在 CREATE 结束时继续)
  • innodb_large_prefix=1

注意

SELECT * FROM information_schema.INNODB_SYS_TABLESPACES;

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

关于mysql 更改 innodb_large_prefix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35847015/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com