diff --git a/QMPlusServer/config/config.go b/QMPlusServer/config/config.go index 60d116fa..ef11b449 100644 --- a/QMPlusServer/config/config.go +++ b/QMPlusServer/config/config.go @@ -31,11 +31,14 @@ type CasbinConfig struct { //casbin配置 } type MysqlAdmin struct { // mysql admin 数据库配置 - Username string `json:"username"` - Password string `json:"password"` - Path string `json:"path"` - Dbname string `json:"dbname"` - Config string `json:"config"` + Username string `json:"username"` + Password string `json:"password"` + Path string `json:"path"` + Dbname string `json:"dbname"` + Config string `json:"config"` + MaxIdleConns int `json:"maxIdleConns"` + MaxOpenConns int `json:"maxOpenConns"` + LogMode bool `json:"maxOpenConns"` } type RedisAdmin struct { // Redis admin 数据库配置 diff --git a/QMPlusServer/init/qmsql/initMysql.go b/QMPlusServer/init/qmsql/initMysql.go index 7a2344fb..b9173cde 100644 --- a/QMPlusServer/init/qmsql/initMysql.go +++ b/QMPlusServer/init/qmsql/initMysql.go @@ -15,8 +15,9 @@ func InitMysql(admin config.MysqlAdmin) *gorm.DB { log.Printf("DEFAULTDB数据库启动异常%S", err) } else { DEFAULTDB = db - DEFAULTDB.DB().SetMaxIdleConns(10) - DEFAULTDB.DB().SetMaxOpenConns(100) + DEFAULTDB.DB().SetMaxIdleConns(admin.MaxIdleConns) + DEFAULTDB.DB().SetMaxOpenConns(admin.MaxOpenConns) + DEFAULTDB.LogMode(admin.LogMode) } return DEFAULTDB } diff --git a/QMPlusServer/static/config/config.json b/QMPlusServer/static/config/config.json index ccdec3c7..2965b6f4 100644 --- a/QMPlusServer/static/config/config.json +++ b/QMPlusServer/static/config/config.json @@ -7,10 +7,13 @@ }, "mysqladmin": { "username": "root", - "password": "Aa@6447985", + "password": "123456", "path": "127.0.0.1:3306", "dbname": "qmPlus", - "config": "charset=utf8\u0026parseTime=True\u0026loc=Local" + "config": "charset=utf8\u0026parseTime=True\u0026loc=Local", + "maxIdleConns": 10, + "maxOpenConns": 100, + "logMode": true }, "qiniu": { "accessKey": "25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ",