我有以下代码,试图测试与postgres的连接:
require 'pg'
conn = PGconn.connect("localhost", 5432, '', '', "puppetdb", "puppetdb", "puppetbdb")
res = conn.exec('select tablename, tableowner from pg_tables')
我收回错误:
试验rb:3:in
initialize': FATAL: password authentication failed for user "puppetdb" (PG::ConnectionBad) from test.rb:3:in
new'from试验rb:3:in `'
不过,我有一个python脚本,它具有相同的凭据,似乎工作得很好:
import psycopg2
try:
conn = psycopg2.connect("dbname='puppetdb' user='puppetdb' host='localhost' port='5432' password='puppetdb'")
考虑到python脚本,我想知道我是否输入了错误的凭证?
最佳答案
您的密码有误(puppetbdb
):
conn = PGconn.connect("localhost", 5432, '', '', "puppetdb", "puppetdb", "puppetdb")