MySQL ERROR 1064 原因(LOAD DATA INFILE)
当我在 MySQL 中运行此 SQL 命令时,
LOAD DATA INFILE 'myFile.csv' INTO myTable FIELDS TERMINATED BY ','
出现此错误:
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
此消息不是很有帮助,它可能是无数语法错误之一的出现。
我如何找出我犯了什么错误,出现了这样一个普遍的“它不起作用”的错误消息?
When I run this SQL commands within MySQL
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
(更改为 INTO TABLE)
取自文档
try
(chage TO to INTO TABLE)
Taken from the documentation
这个 MySQL 错误:
这是 MySQL 可以给出的最令人恼火的答案。您可能犯了大约十亿个错误,从而产生了这个错误。这是 MySQL 糟糕的部分原因,你应该为继续使用它而感到难过。 PostgreSQL 永远不会给出如此蹩脚的错误消息。
你必须分而治之,解决你的问题。
想法:
再看一下这些字符的用法:
{}[]|\'";:,<.>/?!@#$%^&*()_+< /code> 在您的 SQL 语句中,以确保将它们放在正确的位置。如果它们不合适或缺少适当的空格填充,则可能会导致此错误。
确保所有双引号和单引号都有匹配的伙伴。有时,如果您没有正确转义某些内容,SQL 解析器会感到困惑。
重新输入您的整个答案,以确保您的查询中不存在 unicode 字符。
确保分隔单词的空格是空格和普通换行符,而不是 ASCII 空格、无关换行符或空格字符。
确保您以正确的顺序使用正确的关键字。并且您没有省略关键字。 “INTO TABLE blah”与“Into blah”不同,并且该主题有无限变体。
确保在它们所属的地方有分号。删除不属于的内容。
删除 MySQL,如果有人问为什么,请说:“因为开发人员忘记将特定错误链接到有意义的唯一错误消息”。
This MySQL error:
Is the most infuriating answer MySQL could give. 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. PostgreSQL would never give such a lame error message.
You're going to have to divide and conquer your problem.
Ideas:
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.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.
Retype your entire answer to make sure there is not unicode characters in your query.
Make sure the whitespace delimiting your words are spaces and normal newlines, not ascii whitespace, extraneous line feeds or spacing characters.
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.
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".