6

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

当我启动 django 的syncdb命令时,我的所有模型的表都被创建了,但是(我猜它是在创建关系表时),我得到了以下错误:

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

当我要求 django 同步语言环境数据库时,我没有任何问题,这个错误只发生在服务器中......

任何想法?

4

2 回答 2

3

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

You exceed the limitation when you CREATE INDEX.

Although sqlall tells you that none of your key is longer than the limit, you may exceed the limitation because you are using utf8 which uses 3 bytes per character.

One more possible reason is that you have used 'unique_together' in the Meta. This will require a longer index which may cause the issue.

于 2012-01-18T05:06:56.517 回答
0

看起来像django中的一个错误。它可以在 1.2 版本中通过例如http://code.djangoproject.com/changeset/13040修复

于 2010-12-30T15:07:05.727 回答