OperationalError: FATAL: Ident authentication failed for user “dbuser”
出现这个错误的原因还是在于上面pg_hba.conf 文件的设置,Debian系(包括ubuntu)默认的pg_hba.conf 文件对于localhost本地机器的数据库访问方式是ident,它指的是只有Linux shell用户通过同名的postgreSQL 用户才能访问,也就是pg超级用户postgres 只能由linux 用户postgres 登录后操作。要解决类似OperationalError: FATAL: Ident authentication failed for user “postgres”的问题,有两种解决方法:
1. 在执行$ python manage.py shell之前先$su postgres 切换为postgres 用户
2. 修改pg_hba.conf 的客户端访问设置,将laocal 的访问由ident 改为trust,如:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
local all all trust
修改完pg_hba.conf设置记得重启pg。安装了pg_ctl 也可以用pg_ctl reload。