1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 解决 MySQL 8.x 切换数据库访问权限导致创建数据库失败的问题 (#2281)

This commit is contained in:
ssongliu 2023-09-13 18:30:14 +08:00 committed by GitHub
parent 8bc6b409d9
commit 279f8f0e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -72,9 +72,9 @@ func (r *Local) CreateUser(info CreateInfo, withDeleteDB bool) error {
Timeout: 300}) Timeout: 300})
return err return err
} }
grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s", info.Name, user) grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s with grant option;", info.Name, user)
if info.Name == "*" { if info.Name == "*" {
grantStr = fmt.Sprintf("grant all privileges on *.* to %s", user) grantStr = fmt.Sprintf("grant all privileges on *.* to %s with grant option;", user)
} }
if strings.HasPrefix(info.Version, "5.7") || strings.HasPrefix(info.Version, "5.6") { 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) grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, info.Password)

View File

@ -75,9 +75,9 @@ func (r *Remote) CreateUser(info CreateInfo, withDeleteDB bool) error {
} }
return err return err
} }
grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s", info.Name, user) grantStr := fmt.Sprintf("grant all privileges on `%s`.* to %s with grant option;", info.Name, user)
if info.Name == "*" { if info.Name == "*" {
grantStr = fmt.Sprintf("grant all privileges on *.* to %s", user) grantStr = fmt.Sprintf("grant all privileges on *.* to %s with grant option;", user)
} }
if strings.HasPrefix(info.Version, "5.7") || strings.HasPrefix(info.Version, "5.6") { 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) grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, info.Password)