diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go
index 96e49d86a..5e86963d6 100644
--- a/backend/app/service/app_install.go
+++ b/backend/app/service/app_install.go
@@ -446,7 +446,7 @@ func syncById(installId uint) error {
}
func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value interface{}) error {
- if param != "password" && param != "port" {
+ if param != "password" && param != "port" && param != "user-password" {
return nil
}
appInstall, err := appInstallRepo.LoadBaseInfo(appKey, appName)
@@ -458,9 +458,15 @@ func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value
if err != nil {
return err
}
- envKey := "PANEL_DB_ROOT_PASSWORD="
- if param == "port" {
+
+ envKey := ""
+ switch param {
+ case "password":
+ envKey = "PANEL_DB_ROOT_PASSWORD="
+ case "port":
envKey = "PANEL_APP_PORT_HTTP="
+ case "user-password":
+ envKey = "PANEL_DB_USER_PASSWORD="
}
files := strings.Split(string(lineBytes), "\n")
var newFiles []string
diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go
index 60ecb124b..4a90896a0 100644
--- a/backend/app/service/database_mysql.go
+++ b/backend/app/service/database_mysql.go
@@ -19,6 +19,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
+ "github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/1Panel-dev/1Panel/backend/utils/compose"
"github.com/1Panel-dev/1Panel/backend/utils/files"
_ "github.com/go-sql-driver/mysql"
@@ -170,7 +171,7 @@ func (u *MysqlService) Create(ctx context.Context, mysqlDto dto.MysqlDBCreate) (
}
if err := excuteSql(app.ContainerName, app.Password, fmt.Sprintf("create database if not exists `%s` character set=%s", mysqlDto.Name, mysqlDto.Format)); err != nil {
- return nil,err
+ return nil, err
}
tmpPermission := mysqlDto.Permission
if err := excuteSql(app.ContainerName, app.Password, fmt.Sprintf("create user if not exists '%s'@'%s' identified by '%s';", mysqlDto.Username, tmpPermission, mysqlDto.Password)); err != nil {
@@ -264,7 +265,7 @@ func (u *MysqlService) Delete(id uint) error {
if err := excuteSql(app.ContainerName, app.Password, fmt.Sprintf("drop user if exists '%s'@'%s'", db.Name, db.Permission)); err != nil {
return err
}
- if err := excuteSql(app.ContainerName, app.Password, fmt.Sprintf("drop database if exists %s", db.Name)); err != nil {
+ if err := excuteSql(app.ContainerName, app.Password, fmt.Sprintf("drop database if exists `%s`", db.Name)); err != nil {
return err
}
@@ -318,7 +319,7 @@ func (u *MysqlService) ChangePassword(info dto.ChangeDBInfo) error {
if err != nil {
return err
}
- if err := updateInstallInfoInDB(appModel.Key, appInstall.Name, "password", true, info.Value); err != nil {
+ if err := updateInstallInfoInDB(appModel.Key, appInstall.Name, "user-password", true, info.Value); err != nil {
return err
}
}
@@ -447,8 +448,8 @@ func (u *MysqlService) UpdateVariables(updatas []dto.MysqlVariablesUpdate) error
}
}
- if _, ok := info.Value.(int64); ok {
- files = updateMyCnf(files, group, info.Param, loadSizeUnit(info.Value.(int64)))
+ if _, ok := info.Value.(float64); ok {
+ files = updateMyCnf(files, group, info.Param, common.LoadSizeUnit(info.Value.(float64)))
} else {
files = updateMyCnf(files, group, info.Param, info.Value)
}
@@ -685,13 +686,3 @@ func updateMyCnf(oldFiles []string, group string, param string, value interface{
}
return newFiles
}
-
-func loadSizeUnit(value int64) string {
- if value > 1048576 {
- return fmt.Sprintf("%dM", value/1048576)
- }
- if value > 1024 {
- return fmt.Sprintf("%dK", value/1024)
- }
- return fmt.Sprintf("%d", value)
-}
diff --git a/backend/utils/common/common.go b/backend/utils/common/common.go
index f691c3581..b29dc42cc 100644
--- a/backend/utils/common/common.go
+++ b/backend/utils/common/common.go
@@ -116,3 +116,13 @@ func RemoveRepeatElement(a interface{}) (ret []interface{}) {
}
return ret
}
+
+func LoadSizeUnit(value float64) string {
+ if value > 1048576 {
+ return fmt.Sprintf("%vM", value/1048576)
+ }
+ if value > 1024 {
+ return fmt.Sprintf("%vK", value/1024)
+ }
+ return fmt.Sprintf("%v", value)
+}
diff --git a/backend/utils/terminal/exec.go b/backend/utils/terminal/exec.go
index ca63b886b..810d7d84b 100644
--- a/backend/utils/terminal/exec.go
+++ b/backend/utils/terminal/exec.go
@@ -72,7 +72,6 @@ func (sws *ExecWsSession) receiveWsMsg(ctx context.Context, exitCh chan bool) {
for {
_, wsData, err := wsConn.ReadMessage()
if err != nil {
- global.LOG.Errorf("reading webSocket message failed, err: %v", err)
return
}
msgObj := wsMsg{}
diff --git a/backend/utils/terminal/ws_session.go b/backend/utils/terminal/ws_session.go
index 50c8da4ae..2d05ebc2c 100644
--- a/backend/utils/terminal/ws_session.go
+++ b/backend/utils/terminal/ws_session.go
@@ -124,7 +124,6 @@ func (sws *LogicSshWsSession) receiveWsMsg(exitCh chan bool) {
default:
_, wsData, err := wsConn.ReadMessage()
if err != nil {
- global.LOG.Errorf("reading webSocket message failed, err: %v", err)
return
}
msgObj := wsMsg{}
diff --git a/frontend/src/views/database/mysql/setting/index.vue b/frontend/src/views/database/mysql/setting/index.vue
index da8921afe..85fa509ee 100644
--- a/frontend/src/views/database/mysql/setting/index.vue
+++ b/frontend/src/views/database/mysql/setting/index.vue
@@ -18,9 +18,23 @@
v-model="mysqlConf"
:readOnly="true"
/>
+
+ {{ $t('app.defaultConfig') }}
+
{{ $t('commons.button.save') }}
+
+
+
+
+
();
const mysqlConf = ref();
+const useOld = ref(false);
+
const statusRef = ref();
const variablesRef = ref();
const slowLogRef = ref();
@@ -182,6 +198,14 @@ function callback(error: any) {
}
}
+const getDefaultConfig = async () => {
+ loading.value = true;
+ const res = await GetAppDefaultConfig('mysql');
+ mysqlConf.value = res.data;
+ useOld.value = true;
+ loading.value = false;
+};
+
const onSubmitChangeConf = async () => {
let param = {
mysqlName: mysqlName.value,
diff --git a/frontend/src/views/database/redis/setting/index.vue b/frontend/src/views/database/redis/setting/index.vue
index 6bd54b778..fba8c47d1 100644
--- a/frontend/src/views/database/redis/setting/index.vue
+++ b/frontend/src/views/database/redis/setting/index.vue
@@ -18,9 +18,23 @@
v-model="redisConf"
:readOnly="true"
/>
+
+ {{ $t('app.defaultConfig') }}
+
{{ $t('commons.button.save') }}
+
+
+
+
+
@@ -104,7 +118,7 @@ import Persistence from '@/views/database/redis/setting/persistence/index.vue';
import { loadRedisConf, updateRedisConf, updateRedisConfByFile } from '@/api/modules/database';
import i18n from '@/lang';
import { Rules } from '@/global/form-rules';
-import { ChangePort } from '@/api/modules/app';
+import { ChangePort, GetAppDefaultConfig } from '@/api/modules/app';
const extensions = [javascript(), oneDark];
@@ -128,6 +142,8 @@ const activeName = ref('1');
const statusRef = ref();
const persistenceRef = ref();
+const useOld = ref(false);
+
const redisStatus = ref();
const redisName = ref();
@@ -233,6 +249,14 @@ const submtiForm = async () => {
});
};
+const getDefaultConfig = async () => {
+ loading.value = true;
+ const res = await GetAppDefaultConfig('redis');
+ redisConf.value = res.data;
+ useOld.value = true;
+ loading.value = false;
+};
+
const onSaveFile = async () => {
let params = {
header: i18n.global.t('database.confChange'),