diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index f1b3cbf76..07b39b50e 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -196,6 +196,9 @@ func (u *MysqlService) LoadFromRemote(req dto.MysqlLoadDB) error { for i := 0; i < len(databases); i++ { if strings.EqualFold(databases[i].Name, data.Name) && strings.EqualFold(databases[i].MysqlName, data.MysqlName) { hasOld = true + if databases[i].IsDelete { + _ = mysqlRepo.Update(databases[i].ID, map[string]interface{}{"is_delete": false}) + } deleteList = append(deleteList[:i], deleteList[i+1:]...) break } diff --git a/backend/app/service/database_postgresql.go b/backend/app/service/database_postgresql.go index f8439e94c..07843447c 100644 --- a/backend/app/service/database_postgresql.go +++ b/backend/app/service/database_postgresql.go @@ -222,6 +222,9 @@ func (u *PostgresqlService) LoadFromRemote(database string) error { for i := 0; i < len(databases); i++ { if strings.EqualFold(databases[i].Name, data.Name) && strings.EqualFold(databases[i].PostgresqlName, data.PostgresqlName) { hasOld = true + if databases[i].IsDelete { + _ = postgresqlRepo.Update(databases[i].ID, map[string]interface{}{"is_delete": false}) + } deleteList = append(deleteList[:i], deleteList[i+1:]...) break } diff --git a/backend/utils/mysql/client/local.go b/backend/utils/mysql/client/local.go index 44a7693da..3110e3f06 100644 --- a/backend/utils/mysql/client/local.go +++ b/backend/utils/mysql/client/local.go @@ -300,7 +300,10 @@ func (r *Local) SyncDB(version string) ([]SyncDBInfo, error) { } userLines, err := r.ExecSQLForRows(fmt.Sprintf("select user,host from mysql.db where db = '%s'", parts[0]), 300) if err != nil { - return datas, err + global.LOG.Debugf("sync user of db %s failed, err: %v", parts[0], err) + dataItem.Permission = "%" + datas = append(datas, dataItem) + continue } var permissionItem []string diff --git a/backend/utils/mysql/client/remote.go b/backend/utils/mysql/client/remote.go index 48a814e9e..9596ba9de 100644 --- a/backend/utils/mysql/client/remote.go +++ b/backend/utils/mysql/client/remote.go @@ -332,7 +332,10 @@ func (r *Remote) SyncDB(version string) ([]SyncDBInfo, error) { } userRows, err := r.Client.Query("select user,host from mysql.db where db = ?", dbName) if err != nil { - return datas, err + global.LOG.Debugf("sync user of db %s failed, err: %v", dbName, err) + dataItem.Permission = "%" + datas = append(datas, dataItem) + continue } var permissionItem []string