From a22efc90f656200a2cb285f6e1e78b6822d3280f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:32:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#554)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/database_mysql.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index c8174048d..bf3c500bc 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -108,6 +108,9 @@ func (u *MysqlService) Create(ctx context.Context, req dto.MysqlDBCreate) (*mode return nil, err } grantStr := fmt.Sprintf("grant all privileges on `%s`.* to '%s'@'%s'", req.Name, req.Username, tmpPermission) + if req.Name == "*" { + grantStr = fmt.Sprintf("grant all privileges on *.* to '%s'@'%s'", mysql.Username, tmpPermission) + } if app.Version == "5.7.39" { grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, req.Password) } @@ -292,6 +295,9 @@ func (u *MysqlService) ChangeAccess(info dto.ChangeDBInfo) error { return err } grantStr := fmt.Sprintf("grant all privileges on `%s`.* to '%s'@'%s'", mysql.Name, mysql.Username, info.Value) + if mysql.Name == "*" { + grantStr = fmt.Sprintf("grant all privileges on *.* to '%s'@'%s'", mysql.Username, info.Value) + } if app.Version == "5.7.39" { grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, mysql.Password) }