django运行报错了
django.db.utils.NotSupportedError: MySQL 8.0.11 or later is required (found 5.7.30).
Django数据库连接MySQL时报错
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/core/management/commands/runserver.py", line 136, in inner_run
self.check_migrations()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/core/management/base.py", line 581, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/migrations/loader.py", line 58, in __init__
self.build_graph()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/migrations/loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 89, in applied_migrations
if self.has_table():
^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/migrations/recorder.py", line 63, in has_table
with self.connection.cursor() as cursor:
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 316, in cursor
return self._cursor()
^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 292, in _cursor
self.ensure_connection()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 275, in ensure_connection
self.connect()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 258, in connect
self.init_connection_state()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/mysql/base.py", line 266, in init_connection_state
super().init_connection_state()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 225, in init_connection_state
self.check_database_version_supported()
File "/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 200, in check_database_version_supported
raise NotSupportedError(
django.db.utils.NotSupportedError: MySQL 8.0.11 or later is required (found 5.7.30).
/Users/zhaowanjun/Downloads/web/web/myenv/lib/python3.12/site-packages/django/db/backends/base/base.py changed, reloading.
Watching for file changes with StatReloader
Performing system checks...
解决办法
全局搜索找到下面的代码注释掉就可以了
self.check_database_version_supported()