mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 18:10:25 +08:00
只有在数据库用户是root时才执行某些命令
This commit is contained in:
@@ -386,6 +386,19 @@ func (this *APINode) setupDB() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 检查是否为root用户
|
||||
config, _ := db.Config()
|
||||
if config == nil {
|
||||
return nil
|
||||
}
|
||||
dsnConfig, err := mysql.ParseDSN(config.Dsn)
|
||||
if err != nil || dsnConfig == nil {
|
||||
return err
|
||||
}
|
||||
if dsnConfig.User != "root" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 设置Innodb事务提交模式
|
||||
{
|
||||
result, err := db.FindOne("SHOW VARIABLES WHERE variable_name='innodb_flush_log_at_trx_commit'")
|
||||
|
||||
Reference in New Issue
Block a user