Django attempting to connect to mysql without password even when password has been provided

130 views
Skip to first unread message

Coder Dude

unread,
May 27, 2018, 7:24:24 AM5/27/18
to Django users
This is the code in my settings.py :

import pymysql

pymysql.install_as_MySQLdb()

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'learn001',
'USER': 'test01',
'PASSWORD': 'test01', #Password is also test01


}
}

Yet , it is throwing the following error :

django.db.utils.OperationalError: (1045, "Access denied for user 'test01'@'localhost' (using password: NO)".

I don't understand why it is trying to connect without a password. 

It works properly if I create a user with no password and then provide it's username.




Daniel Germano Travieso

unread,
May 27, 2018, 3:03:11 PM5/27/18
to django...@googlegroups.com
Hello! What version of Django are you running?

You may need to provide extra info such as host and port

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mydatabase',
        'USER': 'mydatabaseuser',
        'PASSWORD': 'mypassword',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

Hope it helps


[]'s
Daniel Germano Travieso
Engenharia da Computação Turma: 013
Unicamp

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bc025b3b-58b6-450a-8d37-3fca71568e72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Coder Dude

unread,
May 28, 2018, 12:47:23 AM5/28/18
to Django users
I tried that. Still Doesn't work. I am using django 2.0. 
I found a stackoverflow thread which suggests that it might be a bug with pymysql along with mysql8.

It works properly when i create a user without password and provide it's credentials.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages