[ Agent ] [ App ] - fix mysql init bugs - 7

This commit is contained in:
zeaslity
2023-12-01 14:29:51 +08:00
parent 8e0706a4ba
commit 22ac34ae4e

View File

@@ -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 += " " // 添加空格以便连接多行语句
}
}
// 检查扫描过程中是否有错误