[Fixed] django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.7.33). in Django – Django

by
Ali Hasan
django llama-cpp-python

Quick Fix: Django 4.2 and later requires MySQL 8 or later. To resolve this issue, either downgrade to Django 4.1 or upgrade your MySQL server to version 8.

The Problem:

When attempting migrations using Django’s ‘makemigrations’ command, an error is encountered indicating that MySQL version 8 or later is required, while the user’s current MySQL version is 5.7.33. This error prevents the successful completion of migrations.

The Solutions:

Solution 1: Upgrade MySQL Server

Django versions 4.2 and onwards no longer support MySQL 5.7, requiring MySQL 8 or later. To resolve the issue, upgrade your MySQL server to version 8 or higher. This will ensure compatibility with the latest Django versions.

Solution 2: Update MySQL Version

This error indicates that the installed MySQL version is outdated, in this case MySQL 5.7.33. Django versions 3.2 and above require MySQL 8.0.25 or later, which introduces new features not available in earlier MySQL versions. To resolve this issue:

  1. Upgrade MySQL: Download the latest MySQL version from the official website and follow the installation instructions.
  2. Update Django Settings: In your Django project’s settings.py file, update the DATABASES dictionary, setting ‘ENGINE’ to ‘django.db.backends.mysql’ and providing the necessary parameters like ‘HOST,’ ‘PORT,’ ‘USER,’ ‘PASSWORD,’ and ‘NAME’.
  3. Check MySQL Version: To verify the installed MySQL version, use the SQL query “SELECT @@version;” in a database management tool like phpMyAdmin or MySQL Workbench.

Solution 3: Downgrade Django

To resolve this error, you can downgrade your Django package to an older version that supports MySQL 5.7. Run the following command in your terminal:

pip install Django==3.2.19

This will install Django version 3.2.19, which is compatible with MySQL 5.7. After downgrading Django, you should be able to run the migrations without encountering the error.

Solution 4: Install Django 4.1

Downgrading your Python version is not necessary. Instead, you can install Django 4.1, which supports MySQL 5.7.

To do this, run the following command:

pip3 install django==4.1

Q&A

Error django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.7.33).

Django 3.2 and later versions require MySQL 8.0.25 or later because they use features that are not available in earlier versions of MySQL.

How to fix this error?

To fix this error, you need to upgrade your MySQL installation to version 8 or later.

How to run with mysql 5.7?

You can install an older version of django with pip install Django==3.2.19 command

Video Explanation:

The following video, titled "Django.db.utils.NotSupportedError: MySQL 8 or later is required ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

I got this following error while running the django project. django.db.utils.NotSupportedError: MySQL 8 or later is required (found 5.6.51).