cluster := gocql.NewCluster("1.2.3.4") //replace PublicIP with the IP addresses used by your cluster.
cluster.Keyspace = "testkeyspace"
cluster.Port = 9042
cluster.DisableInitialHostLookup = true
cluster.Authenticator = gocql.PasswordAuthenticator{Username: "test", Password: "testpwd"}
cluster.ProtoVersion = 4 //replace the username and password fields with their real settings.
cluster.Consistency = gocql.Quorum
cluster.CQLVersion = "3.4.5"
cluster.IgnorePeerAddr = true
cluster.DefaultIdempotence = true
cluster.Timeout = time.Second * 30
cluster.ConnectTimeout = time.Second * 30
session, err := cluster.CreateSession()
// session, err := ccfg.CreateSession()
if err != nil {
fmt.Println("error in session", err)
return
}
defer session.Close()我正在尝试连接并遇到问题。我可以在本地连接cqlsh,gocql驱动程序失败,并显示以下错误消息:我已将go1.14和cassandra version设置为cqlsh 5.0.1 | Cassandra 4.0.0.608 | CQL spec 3.4.5 | Native protocol v66
谢谢Chakri
发布于 2020-09-09 17:28:00
您发布的错误指示用户名或密码(或两者)不正确。您需要验证您是否在应用程序中输入了正确的凭据。干杯!
https://stackoverflow.com/questions/63802180
复制相似问题