Error during django's syncdb on server

坚强是说给别人听的谎言 提交于 2019-12-12 10:45:37

问题


I have a full operating locale django app, but I'm having troubles while migrating to the site5 server.

When I launch django's syncdb command, all my models' tables are created, but then (I guess when it's creating relationship tables), I got the following error:

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

I don't have any problem when I ask django to sync the locale db, this error only occurs in the server...

Any idea?


回答1:


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.




回答2:


Looks like a bug in django. It may be fixed in 1.2 release by e.g. http://code.djangoproject.com/changeset/13040



来源:https://stackoverflow.com/questions/4547479/error-during-djangos-syncdb-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!