I have the following settings in my Django application.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'mydatabasename', # Or path to database file if using sqlite3.
'USER': 'davidfaux', # Not used with sqlite3.
'PASSWORD': 'mySecretPassword', # Not used with sqlite3.
'HOST': 'sql.externalhost.com', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
However, when I use manage.py to run my application, I get the following traceback.
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'davidfaux'@'75.156.124.202' (using password: YES)")
75.156.124.202 is the IP address for the dedicated server hosting my Django application. However, my database lies on an external server as I specified in settings.py.
Why is Django seeking this database on the dedicated server rather than an external location as I had specified?
Django isn’t looking for the database on the dedicated server. The returned MySQL error messages means that you are connecting from
75.156.124.202as you can only allow connections from specific hosts with MySQL.This means there is probably some kind of authentication issue, try to connect from your server with a mysql client to
sql.externalhost.comand ensure that you can connect to the database.