From b845fcf6eebcd9eda1360b8d9f9cb20b2cbdbefd Mon Sep 17 00:00:00 2001 From: xujp <1240402516@qq.com> Date: Tue, 16 Nov 2021 10:53:44 +0800 Subject: [PATCH] fix(server):java jdbc connect "Access denied for user 'root'@'127.0.0.1:3306' (using password: Yes)" --- mysql/util.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mysql/util.go b/mysql/util.go index 0276b65ae..1a86a6bc6 100644 --- a/mysql/util.go +++ b/mysql/util.go @@ -8,8 +8,10 @@ import ( "encoding/binary" "fmt" "io" + mrand "math/rand" "runtime" "strings" + "time" "github.com/pingcap/errors" "github.com/siddontang/go/hack" @@ -107,18 +109,11 @@ func AppendLengthEncodedInteger(b []byte, n uint64) []byte { func RandomBuf(size int) ([]byte, error) { buf := make([]byte, size) - - if _, err := io.ReadFull(rand.Reader, buf); err != nil { - return nil, errors.Trace(err) - } - - // avoid to generate '\0' - for i, b := range buf { - if b == 0 { - buf[i] = '0' - } + mrand.Seed(time.Now().UTC().UnixNano()) + min, max := 30, 127 + for i := 0; i < size; i++ { + buf[i] = byte(min + mrand.Intn(max-min)) } - return buf, nil }