Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

685
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda