我的 Django 应用程序中有以下设置。
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.
}
}
但是,当我manage.py
用来运行我的应用程序时,我得到了以下回溯。
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
是托管我的 Django 应用程序的专用服务器的 IP 地址。但是,我的数据库位于我在 settings.py 中指定的外部服务器上。
为什么 Django 在专用服务器上寻找这个数据库,而不是我指定的外部位置?