mysql django.db.utils.InterfaceError: (0, '')

Django MySQL
2020-11-08 19:53 (4 years ago) ytyng
django.db.utils.InterfaceError: "(0, '')"

When this error appears

If this error occurs intermittently when retrieving records or tables, the connection character encoding might not be correct.

If you are connecting with utf8, try switching to utf8mb4 and see if that resolves the issue.

DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "....",
"USER": "....",
"PASSWORD": "....",
"HOST": "....",
"PORT": "",
"OPTIONS": {
"charset": "utf8mb4"
},

Additional note on 2021-08-07

When connecting to a MySQL 5.7 server with a MySQL 8.0 client, the Charset cannot be specified from the client

As mentioned in the above link, when the MySQL client is version 8.0 and the server is version 5.7, the character encoding cannot be specified from the client-side.

Therefore, regarding character encoding, it is best to specify it on the server-side and not specify it from the client-side

(do not specify OPTIONS in the DATABASES).

Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011