Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

681
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!