0
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 版本 cqlsh 5.0.1 | Cassandra 4.0.0.608 | CQL spec 3.4.5 | Native protocol v66

谢谢查克里

4

1 回答 1

0

您发布的错误表明用户名或密码(或两者)不正确。您需要验证您是否在应用程序中输入了正确的凭据。干杯!

于 2020-09-09T09:27:59.893 回答