From 6a717b2517a36e6f9e5789e37df374f88c15be2a Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 8 Jun 2023 11:00:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=20mysql=205.7.42=20(#?= =?UTF-8?q?1286)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/database_mysql.go | 8 ++++---- .../src/views/database/mysql/setting/variables/index.vue | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index b7a532394..914598158 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -195,7 +195,7 @@ func (u *MysqlService) ChangePassword(info dto.ChangeDBInfo) error { } passwordChangeCMD := fmt.Sprintf("set password for '%s'@'%s' = password('%s')", mysql.Username, mysql.Permission, info.Value) - if app.Version != "5.7.39" { + if !strings.HasPrefix(app.Version, "5.7") { passwordChangeCMD = fmt.Sprintf("ALTER USER '%s'@'%s' IDENTIFIED WITH mysql_native_password BY '%s';", mysql.Username, mysql.Permission, info.Value) } if info.ID != 0 { @@ -230,7 +230,7 @@ func (u *MysqlService) ChangePassword(info dto.ChangeDBInfo) error { for _, host := range hosts { if host == "%" || host == "localhost" { passwordRootChangeCMD := fmt.Sprintf("set password for 'root'@'%s' = password('%s')", host, info.Value) - if app.Version != "5.7.39" { + if !strings.HasPrefix(app.Version, "5.7") { passwordRootChangeCMD = fmt.Sprintf("alter user 'root'@'%s' identified with mysql_native_password BY '%s';", host, info.Value) } if err := excuteSql(app.ContainerName, app.Password, passwordRootChangeCMD); err != nil { @@ -347,7 +347,7 @@ func (u *MysqlService) UpdateVariables(updates []dto.MysqlVariablesUpdate) error group := "[mysqld]" for _, info := range updates { - if app.Version != "5.7.39" { + if !strings.HasPrefix(app.Version, "5.7") { if info.Param == "query_cache_size" { continue } @@ -495,7 +495,7 @@ func (u *MysqlService) createUser(app *repo.RootInfo, req dto.MysqlDBCreate) err if req.Name == "*" { grantStr = fmt.Sprintf("grant all privileges on *.* to %s", user) } - if app.Version == "5.7.39" { + if strings.HasPrefix(app.Version, "5.7") { grantStr = fmt.Sprintf("%s identified by '%s' with grant option;", grantStr, req.Password) } if err := excSQL(app.ContainerName, app.Password, grantStr); err != nil { diff --git a/frontend/src/views/database/mysql/setting/variables/index.vue b/frontend/src/views/database/mysql/setting/variables/index.vue index f7e1e2c60..606a9eb89 100644 --- a/frontend/src/views/database/mysql/setting/variables/index.vue +++ b/frontend/src/views/database/mysql/setting/variables/index.vue @@ -76,7 +76,7 @@ {{ $t('database.readRndBufferSizeHelper') }} - + @@ -292,6 +292,9 @@ const onSaveVariables = async () => { }); }; +const showCacheSize = () => { + return mysqlVersion.value.startsWith('5.7'); +}; defineExpose({ acceptParams, });