0

我的 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 在专用服务器上寻找这个数据库,而不是我指定的外部位置?

4

1 回答 1

3

Django 不在专用服务器上寻找数据库。返回的 MySQL 错误消息意味着您正在连接,75.156.124.202因为您只能允许来自特定主机的 MySQL 连接。

这意味着可能存在某种身份验证问题,请尝试使用 mysql 客户端从您的服务器连接到sql.externalhost.com并确保您可以连接到数据库。

于 2012-05-17T17:59:16.730 回答