MySQL/Django/Docker -> 1045, "1045 (28000): Access denied for user 'X'@'xx.xxx.xx.xx' (using password: YES)", '28000'

47 Views Asked by At

I have mariadb/mysql and django running as separate docker containers (both have separate docker-compose.yml files as well).

When I try to build my django docker container using docker-compose build(I have a Dockerfile defined for this with makemigrations and migrate commands in it) my container builds fine and correctly and python manage.py makemigrations and python manage.py migrate work fine as well.

However when I do docker exec -ti <django-container-name> bash and try to run python manage.py makemigrations and python manage.py migrate, it doesn't work.

I get a 1045, "1045 (28000): Access denied for user '<user>'@'<host>' (using password: YES)", '28000'error.

Similarly, when I try to do mysql -h <hostname> -P <port> -u <username> -p I get a bash error saying that mysql doesn't exist (I also get this same error when i do just mysql).

Accessing MariaDB: When I do docker exec -ti <mariadb-container-name> bash and run the mysql command, I am able to see the migrations from the initial django build but nothing else after that.

Where am I going wrong that django can build and do makemigrations/migrate fine but won't run these commands inside the docker container once it is up and running?

I should clarify that mariadb/mysql and django are running on the same docker network but have different ipv4 addresses.

0

There are 0 best solutions below