mysql innodb_large_prefix,MySQL更改innodb_large_prefix

I just setup debian 8.3 on a VM and installed xampp after this Tutorial. Everything is working, until I tried to create a new table:

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

I got the error: #1709 - Index column size too large. The maximum column size is 767 bytes.

Then I found out this comes from the prefix limitation which is limited to 767Byte in Innodb and I can fix this by set the innodb_large_prefix in the my.cnf file. But I can't find the file, its not under /etc/ and theres no /etc/mysql/-folder, the only my.cnf I found is in /opt/lampp/etc/, however, after I added the innodb_large_prefix=1 to the file and restarted lampp. I stil get the same error. What did I do wrong?

edit: SELECT version() returns 5.6.14, so innodb_large_prefix should be supported.

edit2: I know I can work around this by only set part of the the key as index to get under 767Byte. But I want to know here how to config the mysql correctly.

解决方案

Between 5.6.3 and 5.7.7 (that is if you are running MySQL 5.6 or MariaDB 10.0), there are 4 steps:

SET GLOBAL innodb_file_format=Barracuda;

SET GLOBAL innodb_file_per_table=ON;

ROW_FORMAT=DYNAMIC; -- or COMPRESSED (goes on end of CREATE)

innodb_large_prefix=1

Note

SELECT * FROM information_schema.INNODB_SYS_TABLESPACES;

will provide the file_format and row_format. Some other I_S tables provide clues of file_per_table.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值