From 1c22e1cf990851d63b85fc070d11b9807ee8d6cc Mon Sep 17 00:00:00 2001 From: CityFun <31820853+zhengkunwang223@users.noreply.github.com> Date: Mon, 21 Jul 2025 17:52:35 +0800 Subject: [PATCH] fix: Fix the issue where remote databases cannot be selected during application installation (#9589) --- agent/app/service/app_utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agent/app/service/app_utils.go b/agent/app/service/app_utils.go index 68d0cf29b..f1bbec8d2 100644 --- a/agent/app/service/app_utils.go +++ b/agent/app/service/app_utils.go @@ -177,7 +177,7 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI if password, ok := params["PANEL_DB_ROOT_PASSWORD"]; ok { if password != "" { database.Password = password.(string) - if app.Key == "mysql" || app.Key == "mariadb" { + if app.Key == "mysql" || app.Key == "mariadb" || app.Key == constant.AppMysqlCluster { database.Username = "root" } if rootUser, ok := params["PANEL_DB_ROOT_USER"]; ok { @@ -282,6 +282,9 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI } case constant.AppMysql, constant.AppMariaDB, constant.AppMysqlCluster: oldMysqlDb, _ := mysqlRepo.Get(repo.WithByName(dbConfig.DbName), repo.WithByFrom(constant.ResourceLocal)) + if oldMysqlDb.ID == 0 { + oldMysqlDb, _ = mysqlRepo.Get(repo.WithByName(dbConfig.DbName), repo.WithByFrom(constant.AppResourceRemote)) + } resourceId = oldMysqlDb.ID if oldMysqlDb.ID > 0 { if oldMysqlDb.Username != dbConfig.DbUser || oldMysqlDb.Password != dbConfig.Password {