我有这样的代码: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)}它的结果是:[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 应用程序时没有任何问题。有人有想法吗?编辑:这是我的 pg_hba.conf:local all all trusthost all all 127.0.0.1/32 identhost all all ::1/128 ident编辑2:我在我的 postgres 日志中发现了这个:< 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 回答
- 0 关注
- 270 浏览
添加回答
举报
0/150
提交
取消