MySQL - 如果字段内有逗号,则LOAD DATA LOCAL INFILE无法正常工作?

时间:2018-01-31 12:15:00

标签: mysql

我正在尝试将CS​​V加载到MySQL

在现场有逗号之前,一切都进口良好。

system("mysql -uXXXX -pxxx --local-infile XXXX -e \"LOAD DATA LOCAL INFILE '/home/nessus.csv'  INTO TABLE vulnerabilities FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n'IGNORE 1 LINES\"");

如您所见,我正在尝试将Nessus结果扫描(CSV)加载到MySQL中。

"10.0","103.76.180.248","oooo.com","","80","PHP 5.6.x < 5.6.28 Multiple Vulnerabilities","According to its banner, the version of PHP running on the remote web server is 5.6.x prior to 5.6.28. It is, therefore, affected by multiple vulnerabilities :    - A flaw exists in the parse_url() function due to     returning the incorrect host. An unauthenticated, remote     attacker can exploit this to have a multiple impacts     depending on how the function is implemented, which can     include bypassing authentication or conducting open     redirection and server-side request forgery attacks.     (VulnDB 145227)    - An integer overflow condition exists in the     _php_imap_mail() function in file ext/imap/php_imap.c     when handling overly long strings. An unauthenticated,     remote attacker can exploit this to cause a     heap-based buffer overflow, resulting in a denial of     service condition or the execution of arbitrary code.     (VulnDB 146957)    - A flaw exists in the bzcompress() function when handling     overly long strings. An unauthenticated, remote attacker     can exploit this to cause a denial of service condition.     (VulnDB 146975)    - An integer overflow condition exists in the     gdImageAALine() function within file ext/gd/libgd/gd.c     due to improper validation of line limit values. An     unauthenticated, remote attacker can exploit this to     cause an out-of-bounds memory read or write, resulting     in a denial of service condition, the disclosure of     memory contents, or the execution of arbitrary code.     (VulnDB 147321)  Note that this software is reportedly affected by other vulnerabilities as well that have not been fixed yet in version 5.6.28.","Version source    : X-Powered-By: PHP/5.6.27   Installed version : 5.6.27   Fixed version     : 5.6.28","Upgrade to PHP version 5.6.28 or later.  Note that this software is reportedly affected by other vulnerabilities as well. Patches for these have been committed to the source code repository, but until they are incorporated into the next release of the software, manually installing an updated snapshot is the only known solution.","[""http://www.php.net/ChangeLog-5.php#5.6.28""]",""

在短语“根据它的旗帜”中,......逗号进入下一个字段。

我确定FIELDS TERMINATED BY','不正确,但在我的情况下,逗号或双引号可能是实际字段的一部分。

必须有一种方法可以正确导入..任何指导都将不胜感激!

由于

1 个答案:

答案 0 :(得分:0)

你需要告诉MySQL你有值的引号。您可以使用OPTIONALLY ENCLOSED BY子句执行此操作。

system("mysql -uXXXX -pxxx --local-infile XXXX -e \"LOAD DATA LOCAL INFILE '/home/nessus.csv'  INTO TABLE vulnerabilities FIELDS TERMINATED BY ',' OPTIOANLLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'IGNORE 1 LINES\"");