django.db.utils.NotSupportedError: MariaDB 10.5 or later is required
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
django.db.utils.NotSupportedError: MariaDB 10.5 or later is required
- Assistant
Sign in to add a private research label or note.
django.db.utils.NotSupportedError: MariaDB 10.5 or later is required
The error message you're encountering:
django.db.utils.NotSupportedError: MariaDB 10.5 or later is required
indicates that the version of MariaDB installed on your system is older than 10.5, which is the minimum required version for the version of Django you are using. Starting with Django 4.2, MariaDB 10.5 or newer is required due to the use of new features not available in earlier versions.
If you attempt to use Django 4.2 with an older version of MariaDB, Django will raise a NotSupportedError because it relies on database features introduced in MariaDB 10.5.
First, confirm the version of MariaDB installed on your system.
Command Line:
mysql --version
MariaDB Shell:
SELECT VERSION();
Example Output:
10.3.34-MariaDB-0+deb10u1 - Debian 10
If your MariaDB version is older than 10.5, you'll need to upgrade it.
Important: Backup your databases before performing an upgrade to prevent any data loss.
Remove Old MariaDB Source List (if it exists):
sudo rm /etc/apt/sources.list.d/mariadb.list
Add MariaDB APT Repository Key:
sudo apt-get install software-properties-common dirmngr apt-transport-https ca-certificates curl
sudo curl -LsS https://mariadb.org/mariadb_release_signing_key.asc | sudo apt-key add -
Add MariaDB Repository:
Replace focal with your Ubuntu codename (e.g., bionic, focal, jammy).
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.nodesdirect.com/mariadb/repo/10.5/ubuntu focal main'
Update Package Lists:
sudo apt-get update
Upgrade MariaDB Server:
sudo apt-get install mariadb-server
Create MariaDB Repo File:
sudo vi /etc/yum.repos.d/MariaDB.repo
Content:
[mariadb]
name = MariaDB
baseurl = https://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Install MariaDB Server:
sudo yum install MariaDB-server MariaDB-client
Start and Enable MariaDB Service:
sudo systemctl start mariadb
sudo systemctl enable mariadb
After upgrading, run the following command to ensure that the MariaDB system tables are up to date:
sudo mysql_upgrade
sudo systemctl restart mariadb
Confirm that MariaDB is now running version 10.5 or later:
mysql -V
Ensure that your DATABASES setting in settings.py is correctly configured:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # MariaDB uses the MySQL backend
'NAME': 'your_database_name',
'USER': 'your_database_user',
'PASSWORD': 'your_database_password',
'HOST': 'localhost', # or your DB host
'PORT': '3306',
'OPTIONS': {
'sql_mode': 'traditional',
},
}
}
After upgrading, you may need to run Django migrations:
python manage.py migrate
If upgrading MariaDB isn't feasible, you can downgrade Django to a version compatible with your current MariaDB version.
Example: Install Django 4.1, which supports MariaDB 10.2 and above.
pip install 'Django<4.2'
Note: Be aware that using an older version of Django means you won't have access to the latest features and security updates.
If upgrading MariaDB or downgrading Django isn't suitable, consider using a different database backend, such as:
Update your DATABASES setting accordingly.
By following these steps, you should be able to resolve the NotSupportedError and continue developing your Django application with the required database support.
Not yet included in a published release.