提交 94b93e73 编写于 作者: 奇淼(piexlmax 提交者: GitHub

Revert "[feat]: config for TLS connection in init MySQL (#1388)"

This reverts commit a4a240ea.
上级 496bce90
......@@ -69,7 +69,6 @@ mysql:
max-open-conns: 100
log-mode: ""
log-zap: false
init-tls: false
# pgsql connect configuration
# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://gin-vue-admin.com/docs/first_master)
......
......@@ -22,7 +22,6 @@ type GeneralDB struct {
MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
LogMode string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"` // 是否开启Gorm全局日志
LogZap bool `mapstructure:"log-zap" json:"log-zap" yaml:"log-zap"` // 是否通过zap写入日志文件
InitTls bool `mapstructure:"init-tls" json:"init-tls" yaml:"init-tls"` // 初始化时是否开启TLS
}
type SpecializedDB struct {
......
......@@ -18,17 +18,13 @@ type InitDB struct {
// MysqlEmptyDsn msyql 空数据库 建库链接
// Author SliverHorn
func (i *InitDB) MysqlEmptyDsn() string {
initTls := ""
if config.GeneralDB.InitTls {
initTls = "?tls=true"
}
if i.Host == "" {
i.Host = "127.0.0.1"
}
if i.Port == "" {
i.Port = "3306"
}
return fmt.Sprintf("%s:%s@tcp(%s:%s)/"+initTls, i.UserName, i.Password, i.Host, i.Port)
return fmt.Sprintf("%s:%s@tcp(%s:%s)/", i.UserName, i.Password, i.Host, i.Port)
}
// PgsqlEmptyDsn pgsql 空数据库 建库链接
......@@ -46,10 +42,6 @@ func (i *InitDB) PgsqlEmptyDsn() string {
// ToMysqlConfig 转换 config.Mysql
// Author [SliverHorn](https://github.com/SliverHorn)
func (i *InitDB) ToMysqlConfig() config.Mysql {
initTls := ""
if config.GeneralDB.InitTls {
initTls = "&tls=true"
}
return config.Mysql{
GeneralDB: config.GeneralDB{
Path: i.Host,
......@@ -60,7 +52,7 @@ func (i *InitDB) ToMysqlConfig() config.Mysql {
MaxIdleConns: 10,
MaxOpenConns: 100,
LogMode: "error",
Config: "charset=utf8mb4&parseTime=True&loc=Local" + initTls,
Config: "charset=utf8mb4&parseTime=True&loc=Local",
},
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册