I want to integrate MySQL with Django, MySQL is running over Docker and I put the config like this to connect to the db docker with Django:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'restaurant',
'HOST': 'db',
'PORT': '3306',
'USER': 'root',
'PASSWORD': 'root',
'default-character-set': 'utf8',
'OPTIONS': {
'init_command': 'SET default_storage_engine=INNODB',
}
}
}
But when Django is trying to connect to the mysql db, it throws me this error:
I tried to install mysqlclient with pip, but I have this error:
These are the docker-compose.dev.yml and Dockerfile configs.
If someone needs the complete code, here you can find it, and test it with docker-compose -f docker-compose.dev.yml up --build
.
Thanks :).