I have the whole setup working for months on my local computer.
I'm installing on a remote site now.
Created a fresh mysql DB, and created a new user ("someuser") and gave it complete grants, like so -
GRANT ALL PRIVILEGES ON . TO 'someuser'@'localhost' IDENTIFIED BY 'somepassword' WITH GRANT OPTION;
I have sync'd the db, using "python manage.py syncdb" and the correct tables were created. My settings.py has this same user.
But when I try to login a user through the application, and it hits the DB, I see the following in the logs -
(1045, "Access denied for user 'someuser'@'localhost' (using password: YES)")
I logged in through mysql (installed on the same box as django) and checked the grants and it correctly shows -
Grants for someuser@localhost
GRANT ALL PRIVILEGES ON * . * TO 'someuser'@'localhost' IDENTIFIED BY PASSWORD '*thesaltedpasswordOverHere' WITH GRANT OPTION
I don't want to use the root user/password for django, since it doesn't seem the correct way.
Any pointers as to what might be wrong ?
My error message indicated that there wasn't password supplied to the database:
The
manage.py
should pick up the database access credentials from thesettings.py
, that's a specific database user (and of course that user's password as well). It's a security mistake to react to my error message by granting database login privileges to the local user.In my case there were problems with the
settings.py
(we were restructuring our build pipeline from django pipeline to webpack) and I needed to remove pipeline related parts from mysettings.py
for the fix. It's a question why I didn't get any python error message about thesettings.py
problems, but instead I got this error which is not local to the real problem. That error message is just a transitive result of the source problem. Once I fixed themanage.py
, the credentials were picked up from the DATABASE settings as usual and everything went smooth.In our case we were using
django-pipeline
before webpack (more specificallypip
packagesdjango-pipeline-browserify==0.4.1
anddjango-pipeline==1.6.8
), so once we transitioned I had to just remove these lines from settings:Until that I was just getting nonsensical error messages.
Also change the port number to '3307'if MySQl-python 64-bit in settings.py, Then only the connection happening in Windows and MySql 5.7 django.
'3306' for MySQl-python 32-bit
@ mattblang:
In this case it helps if the host is set in the actually used
settings.py
file too.For me it is
/etc/graphite/local_settings.py
where theDATABASES Stanzas
had a wrong value, for HOST there was:'HOST': '127.0.0.1',
Because during the runtime of syncdb command it searched for localhost, I changed it to
'HOST': 'localhost',
Now it looks something like this:
... and now the
syncdb
commandpython manage.py syncdb
runs successfully.It seems that all I have done is:
and then it begin to work.