Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

677
Vistas
how to resolve (1045, "Access denied for user 'User'@'IP or host' (using password: YES)") when build django docker container?

Well, I have multiple databases in django project. One is default and second istest_dev. i have created docker container. and then everything went well till building the container. after that When I try to call my django app api which is using test_dev db for reading data. I have encountered:

OperationalError at /api/projects/

(1045, "Access denied for user 'test_dev'@'xxx.xxx.xxx.xxx' (using password: YES)") 

In settings file, my databases configuration:

{
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': Path(__file__).resolve().parent.parent / 'db.sqlite3',
    },
    "test_dev" : {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': "test",
        'USER': 'test_dev',
        'PASSWORD': 'db_password',
        'HOST': '?=hosted_domain',
        'PORT': '3306',
        'SSL': True
        }
}

If you know any solution. Please help me out of this. Soon I have to put things on production..

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

This is an issue with database access privileges. Either the password is wrong, the user was not granted permissions to the specific database or table that you need, or the Django container's IP address does not match the one bound to the user.

The following SQL:

  1. ensures that the user exists and that login is permitted for that user from any IP address,
  2. ensures that the user has all privileges on the database
CREATE USER IF NOT EXISTS
  'test_dev'@'%' IDENTIFIED BY 'db_password';

GRANT ALL PRIVILEGES
  ON test.*
  TO 'test_dev'@'%';
over 4 years ago · Santiago Trujillo Denunciar

0

I believe that while creating the database for the container, your user has not get the desired permissions, to give permissions use the below snippet.

In your terminal:

mysql -h 127.0.0.1 -P 3306 -u root -p

password is: password (default)

After that, show databases; and use test_dev;

Now, you can check grants by using show grants; command, since the user for all hosts does not have any permissions (or maybe there is no user at all), so use the below command to give privileges:

CREATE USER IF NOT EXISTS 'test_dev'@'%' IDENTIFIED BY 'db_password';

GRANT ALL PRIVILEGES ON test.* TO 'test_dev'@'%';
over 4 years ago · Santiago Trujillo Denunciar

0

Well I solved my problem by changing the engine. I replaced the following line:

'ENGINE': 'django.db.backends.mysql',

with :

 'ENGINE': 'mysql.connector.django',

this code solve my current error but after this i have face an other error that i solve by editing requirements.txt file:

mysql-connector-python==8.0.27

to :

mysql-connector-python==8.0.26
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda