From bf3242445817e1fb9d580b872d512c888ae75a9e Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:58:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20MySQL=208.x=20?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=AF=BC=E8=87=B4=E5=88=9B=E5=BB=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#2283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/mysql/client/local.go | 6 ++++-- backend/utils/mysql/client/remote.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/utils/mysql/client/local.go b/backend/utils/mysql/client/local.go index 6eac5a9e5..187a90079 100644 --- a/backend/utils/mysql/client/local.go +++ b/backend/utils/mysql/client/local.go @@ -72,12 +72,14 @@ func (r *Local) CreateUser(info CreateInfo, withDeleteDB bool) error { Timeout: 300}) return err } - grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s with grant option;", info.Name, user) + grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s", info.Name, user) if info.Name == "*" { - grantStr = fmt.Sprintf("grant all privileges on *.* to %s with grant option;", user) + grantStr = fmt.Sprintf("grant all privileges on *.* to %s", user) } if strings.HasPrefix(info.Version, "5.7") || strings.HasPrefix(info.Version, "5.6") { grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, info.Password) + } else { + grantStr = grantStr + " with grant option;" } if err := r.ExecSQL(grantStr, info.Timeout); err != nil { _ = r.Delete(DeleteInfo{ diff --git a/backend/utils/mysql/client/remote.go b/backend/utils/mysql/client/remote.go index 887f09b02..062ea3534 100644 --- a/backend/utils/mysql/client/remote.go +++ b/backend/utils/mysql/client/remote.go @@ -75,12 +75,14 @@ func (r *Remote) CreateUser(info CreateInfo, withDeleteDB bool) error { } return err } - grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s with grant option;", info.Name, user) + grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s", info.Name, user) if info.Name == "*" { - grantStr = fmt.Sprintf("grant all privileges on *.* to %s with grant option;", user) + grantStr = fmt.Sprintf("grant all privileges on *.* to %s", user) } if strings.HasPrefix(info.Version, "5.7") || strings.HasPrefix(info.Version, "5.6") { grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, info.Password) + } else { + grantStr = grantStr + " with grant option;" } if err := r.ExecSQL(grantStr, info.Timeout); err != nil { if withDeleteDB {