I have created a Django app and which uses MySQL. The settings.py file in the database sections is:
DATABASES = {
'cdraccess': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('CDR_DB_NAME', 'portal2'),
'USER': os.environ.get('CDR_DB_USER', 'cdraccess'),
'HOST': os.environ.get('CDR_DB_HOST', '127.0.0.1'),
'CONN_MAX_AGE': 0,
'PASSWORD': os.environ.get('CDR_DB_PASSWORD', ''),
},
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3',
}
}
I run the app like:
CDR_DB_PASSWORD='password' CDR_DB_HOST='host_name' ./manage.py runserver
but I get the following error:
Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)")
I tried to access the database from terminal, like:
$ mysql --host=[host_name] --user=cdraccess -p portal2
and worked fine.
What is going wrong in here? And what does this "(using password: NO)" mean?
--
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...@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/e1c26a0d-a509-46eb-b496-f7f09161e606%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Galil,
I had a problem like this a couple years ago, and the solution
was to delete the anonymous MySQL guest user as:
mysql> use mysql;
mysql> delete from user where host='localhost' and 'user='';
mysql> flush privileges;
I'm not sure why Django 1.4 was trying to connect as the guest
user when it had a username and password that it was
supposed to be using, but for some reason it was. Deleting
the guest user from MySQL fixed it for me, and is a good idea
for security reasons anyhow.
Using password no. Have you set notempty password with creating table permission?
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fa3b7acf-e015-4e0c-abbe-49da80b752a9%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADTRxJNBV29q6XBTjSK0haKpVNhNe%3Dj5BtUxCmgL%2BwtrAOvEsQ%40mail.gmail.com.
I have created a Django app and which uses MySQL. The settings.py file in the database sections is:
DATABASES = { 'cdraccess': { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.environ.get('CDR_DB_NAME', 'portal2'), 'USER': os.environ.get('CDR_DB_USER', 'cdraccess'), 'HOST': os.environ.get('CDR_DB_HOST', '127.0.0.1'), 'CONN_MAX_AGE': 0, 'PASSWORD': os.environ.get('CDR_DB_PASSWORD', ''), }, 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'db.sqlite3', } }
I run the app like:
CDR_DB_PASSWORD='password' CDR_DB_HOST='host_name' ./manage.py runserver
but I get the following error:
Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)")
I tried to access the database from terminal, like:
$ mysql --host=[host_name] --user=cdraccess -p portal2
and worked fine.
What is going wrong in here? And what does this "(using password: NO)" mean?
'PASSWORD': os.environ.get('CDR_DB_PASSWORD', 'my_password_here'),
Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)")
Why is that happening? Please not that the password is printed and it is correct.
That was helpful James, we are nearly there.You were right the output was "DB Password:", with an empty string. I added my password as default value like:'PASSWORD': os.environ.get('CDR_DB_PASSWORD', 'my_password_here'),
but there is something really strange happening.When I use the default localhost IP as HOST I get the following error:(1045, u"Access denied for user 'cdraccess'@'localhost' (using password: YES)")When I use my actual host IP, either as default value within settings.py or as parameter running the command in the terminal, I get again the previous error:
Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)")
Why is that happening? Please not that the password is printed and it is correct.
'cdraccess': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['CDR_DB_NAME'],
'USER': os.environ['CDR_DB_USER'],
'HOST': os.environ['CDR_DB_HOST'],
'CONN_MAX_AGE': 0,
'PASSWORD': os.environ['CDR_DB_PASSWORD'],
},
'cdraccess': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'portal2', 'USER': 'cdraccess', 'HOST': '127.0.0.1', 'CONN_MAX_AGE': 0, 'PASSWORD': 'yourdbpass', },
'cdraccess': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'portal2',
'USER': 'cdraccess',
'HOST': '127.0.0.1',
'CONN_MAX_AGE': 0,
'PASSWORD': 'mydbpass',
},
(1045, u"Access denied for user 'cdraccess'@'localhost' (using password: YES)")
'cdraccess': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'portal2',
'USER': 'cdraccess',
'HOST': 'my_host_name',
'CONN_MAX_AGE': 0,
'PASSWORD': 'mydbpass',
},
(1045, u"Access denied for user 'cdraccess'@'77.95.177.35' (using password: NO)")
The command: mysql --host=[my_host_name] --user=cdraccess -p portal2 works fine. The host can be given as an IP or like "host_name.net". It works fine in both ways.
And I get the usual error message:(1045, u"Access denied for user 'cdraccess'@'77.95.177.35' (using password: NO)")I have print statements and everything looks correct. It is printed as it is in the settings.py file.One thing I noticed is that the IP 77.95.177.35 is my machine's IP, NOT the host's IP. For some reason the host IP (as it is given in the settings.py file) is replaced in this error message by my machine's IP. Is that normal?