Search code examples
mysqldjangomezzanine

Mezzanine and MySQL: unicode errors


During a mezzanine default setup (via pip) with the MySQL backend, I see unicode errors after I choose to install the included examples.

sudo pip install mezzanine
...
sudo -u mezzanine python manage.py createdb --noinput

This produces the following error, which traces back to 4-byte unicode entities.

django.db.utils.OperationalError: (1366, "Incorrect string value: '\\xEF\\xBE\\x8C\\xE3\\x80\\x8D...' for column 'file' at row 1")

MySQL's default unicode only supports 3-byte entities. But when I go and set they tpe to utf8mb4 (the 4-byte MySQL UTF-8), I hit this error instead:

django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')

The question is this: doesn't anyone use Mezzanine's examples with MySQL? If you do, how do they configure the database, and what version of Mezzanine and of MySQL are you using?


Solution

  • Simple answer: it is a bug. I fixed Mezzanine's configuration, got everything working with MySql 5.6, but those four four-byte unicode warnings persist if you install the example site.

    As long as I do not have the DB in strict mode, where the warnings make the whole transaction fail and the install comes down crashing, this is fairly benign. A small bug, and there is room for finger pointing: Mezzanine uses the full UTF range, and works fine with a number of databases... mySql is the outlier here.