On Mon, Jan 25, 2016 at 8:19 AM, Galil <il...@ajenta.net> wrote: > I changed my settings.py file like this: > > 'cdraccess': { > 'ENGINE': 'django.db.backends.mysql', > 'NAME': 'portal2', > 'USER': 'cdraccess', > 'HOST': '127.0.0.1', > 'CONN_MAX_AGE': 0, > 'PASSWORD': 'mydbpass', > }, > > > And the error message I get is: > > (1045, u"Access denied for user 'cdraccess'@'localhost' (using password: > YES)") > > > Then I changed it to: > > 'cdraccess': { > 'ENGINE': 'django.db.backends.mysql', > 'NAME': 'portal2', > 'USER': 'cdraccess', > 'HOST': 'my_host_name', > 'CONN_MAX_AGE': 0, > 'PASSWORD': 'mydbpass', > }, > > > 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? >
Is the MySQL database running on the same server as the Django instance? If so, I would recommend that it only listen on localhost/127.0.0.1 (it should do this out of the box for most distributions). It's hard to tell which machine you are referring to with the abstracted names you're using. If your client IP is showing up, that would indicate Django is running on your machine, and not the remote server. The server should have no idea what IP you are using at this stage. The IP listed in the error message indicates the source IP of the MySQL connection request. > > 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. > Is this being run from the same server where you have the problematic Django instance? If the DB is running on the same server as the Django instance you're working with, changing the hostname to anything other than 'localhost' or '127.0.0.1' is only going to confuse things and add complication. This feels like you have some wires crossed somewhere with multiple databases and Django installations with different settings.py files. -James -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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/CA%2Be%2BciVSJBk0xii8%3DS8jsRwG0dcXRgV_gMnk9xAd0Cq5GOcZ5Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.