采用官方最简单的例子,始终不行, 希望有经验的大佬帮忙看下,感谢
go.mod
module ck-test
go 1.16
require (
github.com/ClickHouse/clickhouse-go v1.4.1
github.com/jmoiron/sqlx v1.2.1-0.20200614204820-f5f08a7e27f6
)
main.go
package main
import (
_ "github.com/ClickHouse/clickhouse-go"
"github.com/jmoiron/sqlx"
)
func main() {
connect, err := sqlx.Open("clickhouse", "tcp://127.0.0.1:9000?debug=true&read_timeout=10&write_timeout=10")
if err != nil {
panic(err)
}
var items []interface{}
sql := "select * from statics.mysql_slow_log";
if err := connect.Select(&items, sql); err != nil {
panic(err)
}
}
异常:
[clickhouse]host(s)=127.0.0.1:9000, database=default, username=default
[clickhouse][dial] secure=false, skip_verify=false, strategy=random, ident=1, server=0 -> 127.0.0.1:9000
[clickhouse][connect=1][hello] -> Golang SQLDriver 1.1.54213
[clickhouse][connect=1][connect] read error: read tcp 127.0.0.1:49634->127.0.0.1:9000: i/o timeout
[clickhouse]host(s)=127.0.0.1:9000, database=default, username=default
[clickhouse][dial] secure=false, skip_verify=false, strategy=random, ident=2, server=0 -> 127.0.0.1:9000
[clickhouse][connect=2][hello] -> Golang SQLDriver 1.1.54213
[clickhouse][connect=2][connect] read error: read tcp 127.0.0.1:49638->127.0.0.1:9000: i/o timeout
[clickhouse]host(s)=127.0.0.1:9000, database=default, username=default
[clickhouse][dial] secure=false, skip_verify=false, strategy=random, ident=3, server=0 -> 127.0.0.1:9000
[clickhouse][connect=3][hello] -> Golang SQLDriver 1.1.54213
[clickhouse][connect=3][connect] read error: read tcp 127.0.0.1:49641->127.0.0.1:9000: i/o timeout
panic: driver: bad connection
database=default, username=default ?
你不填具体的库名,也没有用户名,密码?