mysql 变化 innodb_large_prefix
mysql change innodb_large_prefix
我刚刚在虚拟机上安装了 debian 8.3,并在此 Tutorial 之后安装了 xampp。一切正常,直到我尝试创建一个新的 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
我收到错误:#1709 - Index column size too large. The maximum column size is 767 bytes.
然后我发现这来自 prefix limitation
,它在 Innodb
中被限制为 767Byte,我可以通过在 my.cnf 文件中设置 innodb_large_prefix 来解决这个问题。但是我找不到文件,它不在 /etc/
下,也没有 /etc/mysql/
文件夹,我找到的唯一 my.cnf
在 /opt/lampp/etc/
中,但是,在我添加之后innodb_large_prefix=1
到文件并重新启动 lampp。我仍然遇到同样的错误。我做错了什么?
编辑: SELECT version()
returns 5.6.14
, 所以应该支持innodb_large_prefix
.
edit2:我知道我可以通过仅将密钥的一部分设置为索引来解决这个问题,使其小于 767 字节。但我想在这里知道如何正确配置 mysql。
介于 5.6.3 和 5.7.7 之间(即如果您是 运行 MySQL 5.6 或 MariaDB 10.0),有 4 个步骤:
- 设置全局innodb_file_format=梭子鱼;
- 设置全局innodb_file_per_table=ON;
- ROW_FORMAT=动态; -- 或压缩(继续创建结束)
- innodb_large_prefix=1
备注
SELECT * FROM information_schema.INNODB_SYS_TABLESPACES;
将提供 file_format 和 row_format。其他一些 I_S 表格提供了 file_per_table.
的线索
转到您的 xampp 并添加此查询:
`mysql>` set global innodb_file_format = `BARRACUDA`;
`mysql>` set global innodb_large_prefix = `ON`;
mysql> set global innodb_file_format = `BARRACUDA`;
mysql> set global innodb_large_prefix = `ON`;
我正在使用 Mysql 5.6.17 和 WAMP 服务器
我通过编辑 my.ini 文件解决了这个问题
找到类别[mysqld]那里添加以下指令
[mysqld]
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_file_per_table = ON
不要忘记保存更改并重新启动所有服务。
对于永久解决方案,请在您的 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'
我使用的是 10.1.38
我刚刚在虚拟机上安装了 debian 8.3,并在此 Tutorial 之后安装了 xampp。一切正常,直到我尝试创建一个新的 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
我收到错误:#1709 - Index column size too large. The maximum column size is 767 bytes.
然后我发现这来自 prefix limitation
,它在 Innodb
中被限制为 767Byte,我可以通过在 my.cnf 文件中设置 innodb_large_prefix 来解决这个问题。但是我找不到文件,它不在 /etc/
下,也没有 /etc/mysql/
文件夹,我找到的唯一 my.cnf
在 /opt/lampp/etc/
中,但是,在我添加之后innodb_large_prefix=1
到文件并重新启动 lampp。我仍然遇到同样的错误。我做错了什么?
编辑: SELECT version()
returns 5.6.14
, 所以应该支持innodb_large_prefix
.
edit2:我知道我可以通过仅将密钥的一部分设置为索引来解决这个问题,使其小于 767 字节。但我想在这里知道如何正确配置 mysql。
介于 5.6.3 和 5.7.7 之间(即如果您是 运行 MySQL 5.6 或 MariaDB 10.0),有 4 个步骤:
- 设置全局innodb_file_format=梭子鱼;
- 设置全局innodb_file_per_table=ON;
- ROW_FORMAT=动态; -- 或压缩(继续创建结束)
- innodb_large_prefix=1
备注
SELECT * FROM information_schema.INNODB_SYS_TABLESPACES;
将提供 file_format 和 row_format。其他一些 I_S 表格提供了 file_per_table.
的线索转到您的 xampp 并添加此查询:
`mysql>` set global innodb_file_format = `BARRACUDA`;
`mysql>` set global innodb_large_prefix = `ON`;
mysql> set global innodb_file_format = `BARRACUDA`;
mysql> set global innodb_large_prefix = `ON`;
我正在使用 Mysql 5.6.17 和 WAMP 服务器 我通过编辑 my.ini 文件解决了这个问题 找到类别[mysqld]那里添加以下指令
[mysqld]
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_file_per_table = ON
不要忘记保存更改并重新启动所有服务。
对于永久解决方案,请在您的 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'
我使用的是 10.1.38