[英]password authentication failed for user "root", postgresSQL and docker
I'm trying to connect to my database using postgres on docker but it says that the password authentication failed.我正在尝试使用 docker 上的 postgres 连接到我的数据库,但它说密码身份验证失败。
My code:我的代码:
const { Client } = require('pg');
const client = new Client({
host: 'localhost',
port: 5432,
user: 'root',
password: 'root',
database: 'mycontacts',
});
client.connect();
docker command to start the postgres container: docker 命令启动postgres容器:
docker run --name postg -e POSTGRES_USER=root2 -e POSTGRES_PASSWORD=root2 -p 5432:5432 -d postgres
Try creating another Postgres container to try and connect and it will work.尝试创建另一个 Postgres 容器来尝试连接,它会起作用。 Else.别的。 password authentication failed while trying to connect into my docker database 尝试连接到我的 docker 数据库时密码验证失败
It ended up being the postgres that i had installed on my pc.它最终成为我在我的电脑上安装的 postgres。
I uninstalled it and now its working!我卸载了它,现在它可以工作了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.