django.db.utils.OperationalError:fe_sendauth:未提供密码

时间:2022-02-18 20:27:16

I have cloned a repo from github and working on it. The project was in django and using postgres as database. This project is now on the production side and I need to make some changes to it. The database specs is :

我克隆了一个来自github的回购并正在研究它。该项目在django并使用postgres作为数据库。该项目现在处于生产阶段,我需要对其进行一些更改。数据库规格是:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # Or path to database file if using sqlite3.
        'NAME': 'project_name',
        'USER': 'admin',
        'PASSWORD': '',
        # Empty for localhost through domain sockets or           '127.0.0.1'
        # for localhost through TCP.
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

I want to run this on my local host but I am not able to. I am getting error:

我想在我的本地主机上运行它,但我无法。我收到错误:

django.db.utils.OperationalError: fe_sendauth: no password supplied

I have searched for this problem but couldn't find a solution that could help me. Can anyone tell me where the problem is?

我已经搜索过这个问题,但找不到可以帮助我的解决方案。谁能告诉我问题出在哪里?

2 个解决方案

#1


11  

If you want to use a local password less connection then you need to remove the values "HOST", "PORT" and "PASSWORD".

如果要使用本地密码减少连接,则需要删除值“HOST”,“PORT”和“PASSWORD”。

With this configuration your connector will try to connect using a unix domain socket which is the only allowed password less connection allowed by default in Postgres

使用此配置,您的连接器将尝试使用unix域套接字进行连接,这是Postgres中默认允许的唯一允许密码连接

#2


0  

I can think of two possible solutions to this problem.

我可以想到这个问题的两种可能的解决方案。

First, if there is no password for the database, remove the PASSWORD key. E.g.:

首先,如果数据库没有密码,请删除PASSWORD键。例如。:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project_name',
        'USER': 'admin',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Second, if there is a password for the database, provide it in the PASSWORD key:

其次,如果有数据库密码,请在PASSWORD键中提供:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project_name',
        'USER': 'admin',
        'PASSWORD': '<YOUR PASSWORD HERE...>',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

#1


11  

If you want to use a local password less connection then you need to remove the values "HOST", "PORT" and "PASSWORD".

如果要使用本地密码减少连接,则需要删除值“HOST”,“PORT”和“PASSWORD”。

With this configuration your connector will try to connect using a unix domain socket which is the only allowed password less connection allowed by default in Postgres

使用此配置,您的连接器将尝试使用unix域套接字进行连接,这是Postgres中默认允许的唯一允许密码连接

#2


0  

I can think of two possible solutions to this problem.

我可以想到这个问题的两种可能的解决方案。

First, if there is no password for the database, remove the PASSWORD key. E.g.:

首先,如果数据库没有密码,请删除PASSWORD键。例如。:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project_name',
        'USER': 'admin',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Second, if there is a password for the database, provide it in the PASSWORD key:

其次,如果有数据库密码,请在PASSWORD键中提供:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project_name',
        'USER': 'admin',
        'PASSWORD': '<YOUR PASSWORD HERE...>',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}