Starting Django on Docker Alpine Results in django.db.utils.OperationalError: (2000, 'Unknown MySQL error')
2020-09-13 06:57 (6 years ago)

Alpine 3.12, django 3.1, mysqlclient 2.0.1
When running python3 ./manage.py runserver 8080,
File "/usr/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/usr/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (2000, 'Unknown MySQL error')
The above error occurred.
The settings are
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '*****',
'USER': '*****',
'PASSWORD': '*****',
'HOST': '*****',
'PORT': '3306',
'OPTIONS': {
'charset': 'utf8mb4',
},
},
}
With this configuration,
the error (2000, 'Unknown MySQL error') occurs when 'charset': 'utf8mb4' is included in the OPTIONS.
When this setting is removed or changed to utf8, the error does not occur.
The detailed cause is unknown.
Related posts
Tips for Solving the 2027 Malformed Packet Error in MySQL
When Installing reportlab in Python on Alpine, It Results in "Not a directory: '/dev/null/.reportlab_mods'"
mysql django.db.utils.InterfaceError: (0, '')
When Connecting to a MySQL 5.7 Server Using a MySQL 8.0 Client, Charset Specification Cannot Be Done from the Client
Please rate this article (No signup or login required)
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.