Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caused by: io.r2dbc.spi.R2dbcBadGrammarException: Specified key was too long #444

Open
Beihaiyumao opened this issue Jan 10, 2024 · 1 comment
Labels
kind/improvement Categorizes issue or PR as related to a improvement.

Comments

@Beihaiyumao
Copy link

系统信息

linux

使用的哪种方式运行?

Docker Compose

在线站点地址

No response

发生了什么?

docker compose 安装用外部的数据库,新建数据的时候 字符集如果是utf8mb4的话 系统初始化数据库会失败。

Caused by: io.r2dbc.spi.R2dbcBadGrammarException: Specified key was too long。

由于 MySQL Innodb 引擎表索引字段长度的限制为 767 字节,因此对于多字节字符集的大字段(或者多字段组合索引),创建索引会出现上面的错误。
以 utf8mb4 字符集 字符串类型字段为例:utf8mb4 是 4 字节字符集,则默认支持的索引字段最大长度是: 767 字节 / 4 字节每字符 = 191 字符,因此在 varchar(255) 或 char(255) 类型字段上创建索引会失败。

方案-修改字符集为utf8 即可。如果有可能的话希望能在文档上标注一下 纯小白的话 可能会卡死在这里

相关日志输出

No response

附加信息

No response

@JohnNiang
Copy link
Member

Thank @Beihaiyumao for reaching out here!

/kind improvement
/area docs

@f2c-ci-robot f2c-ci-robot bot added the kind/improvement Categorizes issue or PR as related to a improvement. label Jan 10, 2024
@ruibaby ruibaby transferred this issue from halo-dev/halo Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement Categorizes issue or PR as related to a improvement.
Projects
None yet
Development

No branches or pull requests

2 participants