gpt4 book ai didi

mysql - 服务器上 django 的 syncdb 期间出错

转载 作者:可可西里 更新时间:2023-11-01 06:49:20 26 4
gpt4 key购买 nike

我有一个完整的语言环境 django 应用程序,但是我在迁移到 site5 服务器时遇到了问题。

当我启动 django 的 syncdb 命令时,我的所有模型表都已创建,但随后(我猜它正在创建关系表),我收到以下错误:

_mysql_exceptions.OperationalError: (1071, 'Specified key was too long; max key length is 1000 bytes')

当我要求 django 同步 locale db 时我没有任何问题,这个错误只发生在服务器......

有什么想法吗?

最佳答案

http://dev.mysql.com/doc/refman/5.0/en/create-index.html

Prefix support and lengths of prefixes (where supported) are storage engine dependent. For example, a prefix can be up to 1000 bytes long for MyISAM tables, and 767 bytes for InnoDB tables.

http://dev.mysql.com/doc/refman/5.0/en/charset-unicode.html

utf8, a UTF-8 encoding of the Unicode character set using one to three bytes per character

您在创建索引时超出了限制。

虽然 sqlall 告诉您没有任何键长于限制,但您可能会超过限制,因为您使用的是 utf8,每个字符使用 3 个字节。

另一个可能的原因是您在 Meta 中使用了“unique_together”。这将需要更长的索引,这可能会导致问题。

关于mysql - 服务器上 django 的 syncdb 期间出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4547479/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com