Django设置:psycopg2.OperationalError:FATAL:用户“indivo”的对等体身份验证失败 [英] Django setting : psycopg2.OperationalError: FATAL: Peer authentication failed for user "indivo"

查看:599
本文介绍了Django设置:psycopg2.OperationalError:FATAL:用户“indivo”的对等体身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是我的setting.py数据库设置



我在Django项目中使用POSTGRESQL设置问题, pre> DATABASES = {
'default':{
'ENGINE':'django.db.backends.postgresql_psycopg2',#'.postgresql_psycopg2','.mysql '或'.oracle'
'NAME':'indivo',#必须是非空字符串
'USER':'indivo',#必须是非空字符串
'PASSWORD':'ritvik',
'HOST':'',#设置为localhost的空字符串。
'PORT':'',#设置为空字符串为默认值。
},
}

现在在postgres后端我所做的是。

  rohit @ rohit-desktop:〜$ sudo su  -  postgres 
postgres @ rohit-desktop:〜$ createuser - -superuser indivo#创建一个超级用户indivo
postgres @ rohit-desktop:〜$ psql#打开psql终端
psql(9.1.8)
输入help作为帮助。

postgres =#\密码indivo#设置密码ritvik
输入新密码:
再次输入:
postgres =#\q #logout
postgres @ rohit-desktop:〜$ createdb -U indivo -O indivo indivo #create db indivo

不幸的是,当我尝试syncdb我收到错误。

  psycopg2.OperationalError:FATAL:用户身份验证失败 indivo

请帮助我在这里做错什么。

解决方案

我有类似的问题,并通过这个答案解决了< a>通过将 localhost 添加到settings.py中的数据库 HOST 设置,因此您的数据库设置应如下所示:

  DATABASES = {
'default':{
'ENGINE':'django.db.backends .postgresql_psycopg2',#'.postgresql_psy ''''''''''''''需要是非空字符串
'USER':'indivo',#必须是非空字符串-空字符串
'PASSWORD':'ritvik',
'HOST':'localhost',#设置为localhost的空字符串。
'PORT':'',#设置为空字符串为默认值。
},
}


I am getting problem in Django project setting with POSTGRESQL.

Here is my setting.py database setting

DATABASES = {
    'default':{
        'ENGINE':'django.db.backends.postgresql_psycopg2', # '.postgresql_psycopg2', '.mysql', or '.oracle'
        'NAME':'indivo', # Required to be non-empty string
        'USER':'indivo', # Required to be non-empty string
        'PASSWORD':'ritvik',
        'HOST':'', # Set to empty string for localhost.
        'PORT':'', # Set to empty string for default.
        },
}

Now in postgres backend what I have done is .

rohit@rohit-desktop:~$ sudo su - postgres
postgres@rohit-desktop:~$ createuser --superuser indivo   # create a super user indivo
postgres@rohit-desktop:~$ psql  # open psql terminal 
psql (9.1.8)
Type "help" for help.

postgres=# \password indivo  # set the password ritvik
Enter new password: 
Enter it again: 
postgres=# \q   #logout 
postgres@rohit-desktop:~$ createdb -U indivo -O indivo indivo  #create db indivo 

Unfortunately when i am trying to syncdb I am getting the error .

psycopg2.OperationalError: FATAL:  Peer authentication failed for user "indivo"

Please help me out what might I am doing wrong here .

解决方案

I have similar problem and solved it with this answer by adding localhost to the database HOST settings in settings.py, so your database settings should look like this:

DATABASES = {
    'default':{
        'ENGINE':'django.db.backends.postgresql_psycopg2', # '.postgresql_psycopg2', '.mysql', or '.oracle'
        'NAME':'indivo', # Required to be non-empty string
        'USER':'indivo', # Required to be non-empty string
        'PASSWORD':'ritvik',
        'HOST':'localhost', # Set to empty string for localhost.
        'PORT':'', # Set to empty string for default.
        },
}

这篇关于Django设置:psycopg2.OperationalError:FATAL:用户“indivo”的对等体身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆