From 0eee2d980738d6459cc75330d547588f17835d67 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:32:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=94=A8=E6=88=B7=E5=90=8D=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20(#2028)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/mysql/client/local.go | 5 ++--- backend/utils/mysql/client/remote.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/backend/utils/mysql/client/local.go b/backend/utils/mysql/client/local.go index 7dd376835..431d65c42 100644 --- a/backend/utils/mysql/client/local.go +++ b/backend/utils/mysql/client/local.go @@ -305,19 +305,18 @@ func (r *Local) SyncDB(version string) ([]SyncDBInfo, error) { } } if len(dataItem.Username) == 0 { - username := loadNameByDB(parts[0], version) + dataItem.Username = loadNameByDB(parts[0], version) if err := r.CreateUser(CreateInfo{ Name: parts[0], Format: parts[1], Version: version, - Username: username, + Username: dataItem.Username, Password: common.RandStr(16), Permission: "%", Timeout: 300, }, false); err != nil { global.LOG.Errorf("sync from remote server failed, err: create user failed %v", err) } - dataItem.Username = parts[0] dataItem.Permission = "%" } else { if isLocal { diff --git a/backend/utils/mysql/client/remote.go b/backend/utils/mysql/client/remote.go index c962de558..810c90a6f 100644 --- a/backend/utils/mysql/client/remote.go +++ b/backend/utils/mysql/client/remote.go @@ -316,19 +316,18 @@ func (r *Remote) SyncDB(version string) ([]SyncDBInfo, error) { i++ } if len(dataItem.Username) == 0 { - userName := loadNameByDB(dbName, version) + dataItem.Username = loadNameByDB(dbName, version) if err := r.CreateUser(CreateInfo{ Name: dbName, Format: charsetName, Version: version, - Username: userName, + Username: dataItem.Username, Password: common.RandStr(16), Permission: "%", Timeout: 300, }, false); err != nil { return datas, fmt.Errorf("sync db from remote server failed, err: create user failed %v", err) } - dataItem.Username = dbName dataItem.Permission = "%" } else { if isLocal {