[英]Can't connect to postgres with 'pg' gem?
我在嘗試測試與postgres的連接時使用以下代碼:
require 'pg'
conn = PGconn.connect("localhost", 5432, '', '', "puppetdb", "puppetdb", "puppetbdb")
res = conn.exec('select tablename, tableowner from pg_tables')
我得到了錯誤:
test.rb:3:in
initialize': FATAL: password authentication failed for user "puppetdb" (PG::ConnectionBad) from test.rb:3:in
新initialize': FATAL: password authentication failed for user "puppetdb" (PG::ConnectionBad) from test.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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.