Starting Django on Docker Alpine Results in django.db.utils.OperationalError: (2000, 'Unknown MySQL error')
Django
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.
Please rate this article (No signup or login required)
Currently unrated
Related posts
How to Fix Display Issues in Django Admin Inlines After Upgrading to 5.1
Return Login and Redirect Views by Hardcoding Social Account Provider in django-allauth (When Using AWS Cognito, etc.)
After Upgrading to Django 5 and Updating Dependencies, SSL: CERTIFICATE_VERIFY_FAILED Error Occurs When Sending Emails
The "first" and "second" Arguments of assertEqual in Django's Unit Tests are Actually "expected" and "actual"
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.