diff --git a/client/auth.go b/client/auth.go index 5a8f3937a..ab6fe75e7 100644 --- a/client/auth.go +++ b/client/auth.go @@ -42,8 +42,14 @@ func (c *Conn) readInitialHandshake() error { return errors.Annotate(c.handleErrorPacket(data), "read initial handshake error") } - if data[0] < MinProtocolVersion { - return errors.Errorf("invalid protocol version %d, must >= 10", data[0]) + if data[0] != ClassicProtocolVersion { + if data[0] == XProtocolVersion { + return errors.Errorf( + "invalid protocol version %d, expected 10. "+ + "This might be X Protocol, make sure to connect to the right port", + data[0]) + } + return errors.Errorf("invalid protocol version %d, expected 10", data[0]) } pos := 1 diff --git a/mysql/const.go b/mysql/const.go index 0cb7fc704..b6da2e736 100644 --- a/mysql/const.go +++ b/mysql/const.go @@ -1,9 +1,10 @@ package mysql const ( - MinProtocolVersion byte = 10 - MaxPayloadLen int = 1<<24 - 1 - TimeFormat string = "2006-01-02 15:04:05" + ClassicProtocolVersion byte = 10 + XProtocolVersion byte = 11 + MaxPayloadLen int = 1<<24 - 1 + TimeFormat string = "2006-01-02 15:04:05" ) const (