halo-dev / halo-dev/docs

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

Open
#444 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/improvement
Dominant language
SCSS
Stars
38
Forks
133
Avg merge
9h 13m
Merged PRs (30d)
7

Description

系统信息

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the Docker Compose documentation for external database setup and the MySQL/InnoDB charset guidance. Reproduce initialization with an external MySQL database using utf8mb4 if the repository provides a documented setup path, then add a clear charset prerequisite and confirm the warning appears where beginners configure the database.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, mysql
Domain
databases, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.