连接到本地postgresql时出现Django身份验证错误

8hhllhi2  于 4个月前  发布在  PostgreSQL
关注(0)|答案(1)|浏览(86)

我一直收到这个错误“用户postgres密码验证失败”。我试图在我的电脑上使用WSL(ubuntu 20.04)启动一个django服务器到我本地笔记本电脑的postgres数据库。
我已经正确设置了我的设置,我可以从我的ubuntu使用连接到psql,所以连接很好。我设置pg_hba信任postgres。
但是当我尝试运行我的django时,我得到了相同的密码验证错误。
请帮助,my pg_hbawsl can connect using psql -U postgresdjango settingserrorpg_ident
试过这个没有帮助
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres" (Ubuntu)

nc1teljy

nc1teljy1#

在pg_hba中,postgres用户的方法最初设置为trust,因此我没有设置密码。
为了确保django数据库配置工作,必须为用户“postgres”提供密码
确保你可以从wsl enter image description here访问postgres
使用命令检查用户的密码

SELECT rolname, rolpassword
FROM pg_authid
WHERE rolname = 'postgres';

字符串
enter image description here
设置密码

ALTER USER postgres PASSWORD '12345678';


应该可以了

相关问题