IdentityServer4中,使用efcore生成PersistedGrant数据库时报错,错误信息如下:
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE INDEX `IX_PersistedGrants_SubjectId_ClientId_Type` ON `PersistedGrants` (`SubjectId`, `ClientId`, `Type`);
Failed executing DbCommand (1ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE INDEX `IX_PersistedGrants_SubjectId_ClientId_Type` ON `PersistedGrants` (`SubjectId`, `ClientId`, `Type`);
...
Specified key was too long; max key length is 1000 bytes
在mysql中建立索引时,key的长度太长,由于mysql默认 default-storage-engine=MyIsam ,MyIsam引擎有key长度限制,超过1000bytes就会报错。
在mysql.ini配置文件中,改为 default-storage-engine=INNOD ,重启即可
修改后组合索引中单列长度不能超过767bytes, 总长度不能超过3072bytes
来源:oschina
链接:https://my.oschina.net/berzhuan/blog/4327354