diff --git a/agent-go/executor/MySqlFunction.go b/agent-go/executor/MySqlFunction.go index 3c566df..2835064 100644 --- a/agent-go/executor/MySqlFunction.go +++ b/agent-go/executor/MySqlFunction.go @@ -49,9 +49,13 @@ func MysqlSqlFileLoad(jackeyLoveIp string, jackeyLoveFileList []string) (bool, [ if sqlStatement == "" || sqlStatement[:2] == "--" || sqlStatement[:2] == "/*" { continue } - // 执行 SQL 语句 - query += sqlStatement + " " - if strings.Contains(sqlStatement, ";") { + + query += sqlStatement + + if strings.HasSuffix(strings.TrimSpace(sqlStatement), ";") { + + fmt.Printf("%s -> %s", jackeyLoveFile, query) + _, err := db.Exec(query) if err != nil { executeError := fmt.Sprintf("[MysqlSqlFileLoad] - jackeyLoveFile %s 执行出错: %s, 错误信息: %s", jackeyLove.Name(), sqlStatement, err.Error()) @@ -60,10 +64,10 @@ func MysqlSqlFileLoad(jackeyLoveIp string, jackeyLoveFileList []string) (bool, [ executeError, } } - // reset query = "" + } else { + query += " " // 添加空格以便连接多行语句 } - } // 检查扫描过程中是否有错误