致命:用户" ubuntu"密码验证失败

时间:2018-01-12 10:56:04

标签: django postgresql

我使用的是djanog 1.11和postgresql 9.5 ###,

我面临以下错误。但我的django数据库设置不同。

  DATABASES = {
        'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME':'test_db',
        'USERNAME':'rails',
        'PASSWORD':'rails',
        'HOST':'localhost',
        'PORT':'5432',
        }
    }

我认为django将用户作为ubuntu用户传递,它的系统已登录用户。

System check identified no issues (0 silenced).
    Unhandled exception in thread started by <function wrapper at 0x7f39fbfe5488>
    Traceback (most recent call last):
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
        fn(*args, **kwargs)
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
        self.check_migrations()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 422, in check_migrations
        executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
        self.loader = MigrationLoader(self.connection)
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
        self.build_graph()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 209, in build_graph
        self.applied_migrations = recorder.applied_migrations()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
        self.ensure_schema()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-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 "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
        return self._cursor()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
        self.ensure_connection()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
        self.connect()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
        six.reraise(dj_exc_type, dj_exc_value, traceback)
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
        self.connect()
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
        self.connection = self.get_new_connection(conn_params)
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
        connection = Database.connect(**conn_params)
      File "/home/ubuntu/sooky_env/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
        conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
    django.db.utils.OperationalError: FATAL:  password authentication failed for user "ubuntu"
    FATAL:  password authentication failed for user "ubuntu"

1 个答案:

答案 0 :(得分:0)

您的设置有误。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': '<db_name>',
        'HOST': '<db_host>',
        'USER': '<postgres_user>',
        'PORT': '5432',
        'PASSWORD': '<postgres_user_password>',
    },
}

它是“用户”而非“用户名”