简体   繁体   English

django.db.utils.OperationalError:fe_sendauth:迁移 django 应用程序时未提供密码

[英]django.db.utils.OperationalError: fe_sendauth: no password supplied when migrating django app

I'm a beginner with Django working on an open source project, which has been very challenging since it only gives build instructions for Mac, and not Linux.我是 Django 的初学者,从事一个开源项目,这非常具有挑战性,因为它只为 Mac 提供构建说明,而不是 Linux。 So, on my Ubuntu server, I've managed to install all the packages and fix a few initial bugs, but now, when I do python manage.py migrate , I'm stuck with this error: django.db.utils.OperationalError: fe_sendauth: no password supplied因此,在我的 Ubuntu 服务器上,我已经成功安装了所有软件包并修复了一些初始错误,但是现在,当我执行python manage.py migrate时,我遇到了这个错误: django.db.utils.OperationalError: fe_sendauth: no password supplied

I'm totally stuck here: I'm having a tough time understanding the error message, and other solutions aren't much help.我完全被困在这里:我很难理解错误消息,其他解决方案也没有多大帮助。 Other solutions indicate that you have to change the DATABASES setting in the settings.py, but the setting has no PASSWORD attribute and it's only linked to sqlite:其他解决方案表明您必须更改 settings.py 中的 DATABASES 设置,但该设置没有 PASSWORD 属性,并且仅链接到 sqlite:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
DATABASES['default'] = dj_database_url.config()

The error doesn't trace back to any specific lines of code so I'm guessing its more related to psycopg2 or django than the code itself, but I'm not sure how to go about fixing it.该错误不会追溯到任何特定的代码行,所以我猜测它与 psycopg2 或 django 的关系比代码本身更重要,但我不确定如何修复它。 I'm using Python 2.7.17 and Ubuntu 18.04.5.我正在使用 Python 2.7.17 和 Ubuntu 18.04.5。 Here's the full error message:这是完整的错误消息:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 52, in __init__
    self.build_graph()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 210, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 254, in cursor
    return self._cursor()
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 229, in _cursor
    self.ensure_connection()
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 213, in ensure_connection
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 213, in ensure_connection
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/local/lib/python2.7/dist-packages/psycopg2/__init__.py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: fe_sendauth: no password supplied

Again, I'm very new to Django and Postgres, so I may be missing something obvious.同样,我对 Django 和 Postgres 很陌生,所以我可能会遗漏一些明显的东西。 It's equally likely that the code just doesn't work on Linux or that there's some unfixed bug in it.该代码同样可能无法在 Linux 上运行,或者其中存在一些未修复的错误。 Any help would be appreciated.任何帮助,将不胜感激。

As Vineet pointed out, the DATABASES['default'] = dj_database_url.config() line was overwriting the configuration, and as a result the 'PASSWORD' and other attributes existed and were blank.正如 Vineet 指出的那样, DATABASES['default'] = dj_database_url.config()行覆盖了配置,因此 'PASSWORD' 和其他属性存在并且为空白。 I added this line after it:我在它之后添加了这一行:

del DATABASES['default']['PASSWORD'], DATABASES['default']['HOST'], DATABASES['default']['PORT']

and the problem has been solved.并且问题已经解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS-DJANGO-格式错误:OperationalError:fe_sendauth:未提供密码 - AWS - DJANGO - Error in formatting: OperationalError: fe_sendauth: no password supplied Django 4 使用密码文件连接到 Postgresql:“fe_sendauth:未提供密码” - Django 4 connection to Postgresql using passfile: "fe_sendauth: no password supplied" psycopg2.OperationalError:fe_sendauth:未提供密码 - psycopg2.OperationalError: fe_sendauth: no password supplied SQLAlchemy (psycopg2.OperationalError) fe_sendauth:未提供密码 - SQLAlchemy (psycopg2.OperationalError) fe_sendauth: no password supplied Python 和 Postgresql:OperationalError:fe_sendauth:未提供密码 - Python and Postgresql: OperationalError: fe_sendauth: no password supplied 在新应用程序中添加时“django.db.utils.OperationalError: no such table” - "django.db.utils.OperationalError: no such table" when adding in new app Django fe_sendauth:未提供密码错误,无法连接到 postgres 数据库 - Django fe_sendauth: no password supplied error, unable to connect to postgres database fe_sendauth:Composer 中没有提供密码 - fe_sendauth: no password supplied in Composer django.db.utils.OperationalError: 没有这样的表 Django 2 - django.db.utils.OperationalError: no such table Django 2 Django:django.db.utils.OperationalError: 没有这样的列 - Django:django.db.utils.OperationalError: no such column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM