3

我目前在运行 Django 应用程序 Scalica 时遇到了一些问题。昨晚它工作得很好,我一定是做错了什么把它弄坏了——我只是不确定它是什么。

当我尝试运行以下内容时:

ubuntu@ip-172-31-28-29:~/largescale/scalica/web/scalica$ python manage.py migrate

我收到此错误消息:

django.db.utils.OperationalError: (1045, "Access denied for user 'appserver'@'localhost' (using password: YES)")

问题是,我不相信这个应用程序甚至应该知道用户应用服务器。我尝试执行的 manage.py 文件的 settings.DATABASES 设置如下:

# Database
DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.mysql',
    'OPTIONS': {
      'read_default_file': os.path.join(BASE_DIR, '..', '..', 'db', 'my.cnf'),
    },
  }
}

我正在远程运行 Scalica,并将数据保存在远程服务器上以将其显示到网页上。然后由在本地运行的刮板刮取,然后将其保存到 appserver 用户下的数据库中。所以 appserver 根本不应该访问 Scalica 数据库。我认为 manage.py 调用了错误的 settings.py。如果是这种情况,我该如何解决?如果我的猜测是错误的,如果有人可以提供一些建议,那将很有帮助。

下面是manage.py的内容:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "scalica.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

编辑

我已经尝试删除现有用户 appserver 并重新创建它,授予它对本地应用程序使用的数据库 metrix1 和 metrix2 的权限。然而,这并没有解决我的问题。我在远程运行与 appserver 无关的 Scalica 应用程序时遇到问题。

以下是 appserver 的用户权限:

| 'appserver'@'localhost'        | def           | SELECT                  | NO           |
| 'appserver'@'localhost'        | def           | INSERT                  | NO           |
| 'appserver'@'localhost'        | def           | UPDATE                  | NO           |
| 'appserver'@'localhost'        | def           | DELETE                  | NO           |
| 'appserver'@'localhost'        | def           | CREATE                  | NO           |
| 'appserver'@'localhost'        | def           | DROP                    | NO           |
| 'appserver'@'localhost'        | def           | RELOAD                  | NO           |
| 'appserver'@'localhost'        | def           | SHUTDOWN                | NO           |
| 'appserver'@'localhost'        | def           | PROCESS                 | NO           |
| 'appserver'@'localhost'        | def           | FILE                    | NO           |
| 'appserver'@'localhost'        | def           | REFERENCES              | NO           |
| 'appserver'@'localhost'        | def           | INDEX                   | NO           |
| 'appserver'@'localhost'        | def           | ALTER                   | NO           |
| 'appserver'@'localhost'        | def           | SHOW DATABASES          | NO           |
| 'appserver'@'localhost'        | def           | SUPER                   | NO           |
| 'appserver'@'localhost'        | def           | CREATE TEMPORARY TABLES | NO           |
| 'appserver'@'localhost'        | def           | LOCK TABLES             | NO           |
| 'appserver'@'localhost'        | def           | EXECUTE                 | NO           |
| 'appserver'@'localhost'        | def           | REPLICATION SLAVE       | NO           |
| 'appserver'@'localhost'        | def           | REPLICATION CLIENT      | NO           |
| 'appserver'@'localhost'        | def           | CREATE VIEW             | NO           |
| 'appserver'@'localhost'        | def           | SHOW VIEW               | NO           |
| 'appserver'@'localhost'        | def           | CREATE ROUTINE          | NO           |
| 'appserver'@'localhost'        | def           | ALTER ROUTINE           | NO           |
| 'appserver'@'localhost'        | def           | CREATE USER             | NO           |
| 'appserver'@'localhost'        | def           | EVENT                   | NO           |
| 'appserver'@'localhost'        | def           | TRIGGER                 | NO           |
| 'appserver'@'localhost'        | def           | CREATE TABLESPACE       | NO           |
+--------------------------------+---------------+-------------------------+--------------+
4

0 回答 0