Django无法访问数据库/拒绝访问用户@localhos

2024-10-02 18:21:20 发布

您现在位置:Python中文网/ 问答频道 /正文

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

当我尝试运行以下命令时:

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

我收到以下错误消息:

^{pr2}$

问题是,我不认为这个应用程序应该知道用户appserver。这个管理.py我试图在其中执行的文件,有settings.数据库像这样设置:

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

我正在远程运行Scalica,并将数据保存在远程服务器上以显示在网页上。然后由一个本地运行的scraper抓取,然后保存到appserver user下的数据库中。所以appserver根本不应该访问Scalica数据库。我认为管理.py打错电话了设置.py. 如果是这样的话,我该怎么解决呢?如果我的猜测是错误的,如果有人能提供一些建议,那将是有帮助的。在

以下是管理.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的权限,这两个数据库由本地应用程序使用。然而,这并没有解决我的问题。我有一个远程运行的Scalica应用程序遇到问题,应该与appserver无关。

以下是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           |
+--------------------------------+---------------+-------------------------+--------------+

Tags: no用户frompyimport数据库应用程序localhost