Skip to content

Commit

Permalink
fix: 解决数据库用户名显示错误的问题 (#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu authored and wanghe-fit2cloud committed Aug 22, 2023
1 parent f0e78c4 commit 0eee2d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions backend/utils/mysql/client/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions backend/utils/mysql/client/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0eee2d9

Please sign in to comment.