I have an issue with creating test database. I use mysql for db and docker compose.
I have no problem running docker containers with docker-compose, but when I run test it spits this error message.
Note that the name of django service is web, and mysql service is db.
Creating sociallogin_web_run ... done
Creating test database for alias 'default'...
Got an error creating the test database: (1044, "Access denied for user 'myuser'@'%' to database 'test_mydb'")
version: "3.9"
services:
db:
image: mysql:8
env_file:
- .env
command:
- --default-authentication-plugin=mysql_native_password
restart: always
# ports:
# - "3306:3306"
# volumes:
# - data:/var/lib/mysql
web:
build: .
command: >
sh -c "python manage.py wait_for_db &&
python manage.py makemigrations &&
python manage.py migrate &&
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
env_file:
- .env
# volumes:
# data:
my .env file looks like this:
MYSQL_ROOT_PASSWORD=rootpass
MYSQL_USER=exampleuser
MYSQL_PASSWORD=examplepass
MYSQL_DATABASE=exampledb
MYSQL_PORT=3306
SECRET_KEY=exmaple_random_characters
my settings for DATABASES
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('MYSQL_DATABASE'),
'USER': os.environ.get('MYSQL_USER'),
'PASSWORD': os.environ.get('MYSQL_PASSWORD'),
'PORT': os.environ.get('MYSQL_PORT'),
'HOST': 'db',
}
}
I looked at
SO, and I even tried
this. It didn't help me.
Anyone who's been stuck at similiar problem?
Thanks guys in advance.