简体   繁体   English

MySQL错误1064原因(LOAD DATA INFILE)

[英]MySQL ERROR 1064 cause (LOAD DATA INFILE)

When I run this SQL commands within MySQL 当我在MySQL中运行此SQL命令时

LOAD DATA INFILE 'myFile.csv' INTO myTable FIELDS TERMINATED BY ','

I get this error: 我收到此错误:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to
use near 'TO myTable FIELDS TERMINATED BY ','' at line 1

This message isn't very helpful, it can appear for one of countless syntax errors. 此消息不是很有帮助,可能会出现无数语法错误之一。

How do I find out what mistake I've made with such a generalized "it won't work" error message? 我如何找出这样一个笼统的“将无法正常工作”的错误消息?

try 尝试

LOAD DATA INFILE 'myFile.csv' INTO TABLE myTable 
FIELDS TERMINATED BY ','

(chage TO to INTO TABLE) (切换到INTO TABLE)

Taken from the documentation 取自文档

This MySQL error: 这个MySQL错误:

You have an error in your SQL syntax; check the manual.

Is the most infuriating answer MySQL could give. 是MySQL可能给出的最令人毛骨悚然的答案。 There are about a billion mistakes you could have made which produces this error. 您可能犯了大约十亿个错误,导致了此错误。 It's part of the reason MySQL sucks and you should feel bad for continuing to use it. 这是MySQL很烂的部分原因,您应该为继续使用它感到难过。 PostgreSQL would never give such a lame error message. PostgreSQL永远不会给出如此a脚的错误消息。

You're going to have to divide and conquer your problem. 您将不得不分而治之。

Ideas: 思路:

  1. Take a second look at usage of these characters: {}[]|\\'";:,<.>/?!@#$%^&*()_+ in your SQL statement to make sure you put them in the right place. If they are out of place or lacking proper whitespace padding it could causes this error. 再看看这些字符的用法: {}[]|\\'";:,<.>/?!@#$%^&*()_+在您的SQL语句中,以确保将它们放在如果它们不正确或缺少适当的空白填充,则可能会导致此错误。

  2. Make sure all of your double quotes and single quotes have matching partners. 确保所有双引号和单引号都有匹配的伙伴。 Sometimes the SQL parser gets confused if you don't escape something right. 如果您无法避免某些错误,有时SQL解析器会感到困惑。

  3. Retype your entire answer to make sure there is not unicode characters in your query. 重新输入整个答案,以确保查询中没有Unicode字符。

  4. Make sure the whitespace delimiting your words are spaces and normal newlines, not ascii whitespace, extraneous line feeds or spacing characters. 确保分隔单词的空格是空格和常规换行符,而不是ascii空格,多余的换行符或空格字符。

  5. Make sure you are using the correct keywords in the correct order. 确保以正确的顺序使用正确的关键字。 And that you have not omitted a keyword. 而且您还没有省略关键字。 "INTO TABLE blah" is not the same as "Into blah", and infinite variants on this theme. “ INTO TABLE blah”与“ Into blah”不同,并且是该主题的无限变体。

  6. Make sure you have semicolons where they belong. 确保您在分号所属的地方。 Remove the ones that don't belong. 删除不属于的内容。

Delete MySQL, and if anyone asks why, then say: "Because the developers forgot to link specific errors to meaningful unique error messages". 删除MySQL,如果有人问为什么,请说:“因为开发人员忘记了将特定错误链接到有意义的独特错误消息”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM