mysql改变innodb_large_prefix

yan*_*nny 5 mysql innodb utf8mb4

我只是在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
Run Code Online (Sandbox Code Playgroud)

我得到了错误:#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/的唯一,但是,在我添加到文件并重新启动lampp之后.我仍然得到同样的错误.我做错了什么?my.cnf/opt/lampp/etc/innodb_large_prefix=1

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

edit2:我知道我可以解决这个问题,只需将键的一部分设置为索引即可获得767Byte.但我想知道如何正确配置mysql.

Ric*_*mes 13

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

  • SET GLOBAL innodb_file_format = Barracuda;
  • SET GLOBAL innodb_file_per_table = ON;
  • ROW_FORMAT = DYNAMIC; - 或COMPRESSED(在CREATE结束时)
  • innodb_large_prefix = 1

注意

SELECT * FROM information_schema.INNODB_SYS_TABLESPACES;
Run Code Online (Sandbox Code Playgroud)

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

  • 尊敬的Downvoter先生:如果我的答案有问题,请告诉我;我会解决的。 (2认同)

小智 8

对于永久解决方案,请在您的 mariadb My.INI 文件中添加以下内容-

## Innodb settings to bypass error of max size 737
innodb-file-format=barracuda
innodb-file-per-table=ON
innodb-large-prefix=ON
## Above 3 didnot work so i added below
innodb_default_row_format = 'DYNAMIC'
Run Code Online (Sandbox Code Playgroud)

我使用的是 10.1.38


Vla*_*ero 7

我在WAMP Server上使用Mysql 5.6.17,我通过编辑my.ini文件解决了该问题。找到类别[mysqld],然后添加以下说明

[mysqld]
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_file_per_table = ON
Run Code Online (Sandbox Code Playgroud)

不要忘记保存更改并重新启动所有服务。