Search code examples
pythonmysqldjangoutf8mb4

django inspectdb utf8mb4 error


Python manage.py inspectdb is giving following error even after all tables are having CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci

from django.db import models

Unable to inspect table 'execution'

The error was: (3719, "3719: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.", None)


Solution

  • I encountered the exact same issue lately. I raised a bug request to Django, but Django do not accept it as their bug.

    MySQL 8 has switched from UTF8MB3 to UTF8MB4 as the default charset. As of 8.0.11 if you access a table that was created with the previous version a warning is returned encouraging you to switch to UTF8MB4.

    When you run the inspectdb the INFORMATION_SCHEMA tables are still in UTF8MB3 so you get the warning returned to Django, which Django is currently unable to ignore.

    I have a fully worked example of how to get around this error on the Django bug ticket: https://code.djangoproject.com/ticket/29678

    I have been able to fully use MySQL 8.0.12 as a backend for a robust Django application so once you get past this issue you should hopefully be okay.