我正在使用数字海洋液滴,并使用本教程https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04设置它。当我使用我的用户连接时,postgres在机器上工作。
当我试图使用node.js连接到postgres数据库时,它不起作用。
var pg = require('pg');
var conString = "postgres://myuser:password@localhost:5432/dbname";
var client = new pg.Client(conString);
client.connect();
当我查看node.js错误日志时,它说
error: password authentication failed for user "myuser"
at Connection.parseE (/usr/lib/node_modules/pg/lib/connection.js:572:11)
at Connection.parseMessage (/usr/lib/node_modules/pg/lib/connection.js:396:$
at Socket.<anonymous> (/usr/lib/node_modules/pg/lib/connection.js:132:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
我不知道密码是什么意思。我输入的唯一密码是我用来在Ubuntu上创建myuser的密码,就像教程中提到的那样。我确信密码与我为我的用户输入的密码相匹配。我也试图让它空白,但这也不起作用。
但是我假设连接正常,而且只有身份验证失败了?新的postgres数据库有默认密码吗?
发布于 2017-06-06 11:57:02
好吧,我找到了一条路
$ sudo -u myuser psql myuser
postgres=# \password myuser
然后它问我的密码,我输入了与连接字符串相同的密码,现在它工作起来了,很奇怪。
https://stackoverflow.com/questions/44389222
复制相似问题