Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions backend/utils/mysql/client/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 4 additions & 2 deletions backend/utils/mysql/client/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down