第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang lib/pg 無法連接到 postgres

Golang lib/pg 無法連接到 postgres

Go
ibeautiful 2021-12-06 14:55:34
我有這樣的代碼:package mainimport (        "database/sql"        "fmt"        "log"        _ "github.com/lib/pq")func main() {        db, err := sql.Open("postgres", "user=postgres dbname=vagrant sslmode=disable")        if err != nil {                log.Fatal(err)        }        rows, err := db.Query("SELECT 3+5")        if err != nil {                log.Fatal(err)        }        fmt.Println(rows)}它的結(jié)果是:[vagrant@localhost go-postgres]$ go run test.go2015/12/19 11:03:53 pq: Ident authentication failed for user "postgres"exit status 1但我可以訪問 postgres:[vagrant@localhost go-postgres]$ psql -U postgres vagrantpsql (9.4.4)Type "help" for help.vagrant=#而且我在使用帶有 postgres 的 Rails 應(yīng)用程序時沒有任何問題。有人有想法嗎?編輯:這是我的 pg_hba.conf:local   all             all                                     trusthost    all             all             127.0.0.1/32            identhost    all             all             ::1/128                 ident編輯2:我在我的 postgres 日志中發(fā)現(xiàn)了這個:< 2015-12-19 12:13:05.094 UTC >LOG:  could not connect to Ident server at address "::1", port 113: Connection refused< 2015-12-19 12:13:05.094 UTC >FATAL:  Ident authentication failed for user "postgres"< 2015-12-19 12:13:05.094 UTC >DETAIL:  Connection matched pg_hba.conf line 84: "host    all             all             ::1/128                 ident"我認為它真的會有所幫助;)
查看完整描述

2 回答

?
嚕嚕噠

TA貢獻1784條經(jīng)驗 獲得超7個贊

好的,正確的連接字符串是:

"user=postgres host=/tmp dbname=vagrant sslmode=disable"

我假設(shè) pg 庫使用與psqlruby 驅(qū)動程序相同的默認值。學(xué)過的知識。



查看完整回答
反對 回復(fù) 2021-12-06
?
紅顏莎娜

TA貢獻1842條經(jīng)驗 獲得超13個贊

在控制臺中運行:

psql "user=postgres dbname=vagrant sslmode=disable"

如果您無法連接,則需要更改 sslmode 否則我會考慮更多。


查看完整回答
反對 回復(fù) 2021-12-06
  • 2 回答
  • 0 關(guān)注
  • 307 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號