installing mysqlclient in django

Dec 15, 2023    |   

I have trouble installing mysqlclient for django both on Windows and Ubuntu directly. But when I created an virtual environment and then install mysqlclient it got passed.

1. create virtualenv

virtualenv -p /usr/bin/python3.8 venv38
cd venv38
source bin/activate

2. install django

pip install django==4.2.8

3. install mysqlclient

pip install mysqlclient

4. start a new django project

python manage.py startproject <your-project-name>

5. run django development server

python manage.py runserver 0.0.0.0:80

Django 4.2 only support mysql8 but what I want to do is to run inspectdb to dump my old mysql database to django models. To solve this problem just change 'lib/python3.8/site-packages/django/db/backends/base/base.py' to make it not raise error or downgrade your django version.