MySQL 中的错误 1064 (42000)
我正在尝试使用从 MS SQL Azure 数据库创建的数据库转储来填充新的 MySQL 空数据库,但出现以下错误
第 1 行出现错误 1064 (42000):您的 SQL 语法有错误; 检查与您的 MySQL 服务器版本对应的手册 在第 1 行“I”附近使用的正确语法
我使用 mysqldump 来执行此操作,并在命令提示符中使用了类似于以下内容的命令:
mysql --user=rootusername --pasword=password databasename < dumpfilename.sql
Mysqldump 花了大约 30 分钟来显示此错误消息。
I am trying to populate a new MySQL empty database with a db dump created from MS SQL Azure database, and I get the following 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 'I ' at line 1
I used mysqldump to perform this operation and used command similar to the following in the command prompt:
mysql --user=rootusername --pasword=password databasename < dumpfilename.sql
Mysqldump took about 30 minutes to display this error message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
当语句周围缺少 DELIMITER 时,通常会出现错误 1064,例如:创建函数、创建触发器。
确保在每个语句之前添加 DELIMITER $$ 并以 $$ DELIMITER 结束
像这样:
Error 1064 often occurs when missing DELIMITER around statement like : create function, create trigger..
Make sure to add DELIMITER $$ before each statement and end it with $$ DELIMITER
like this:
检查你的转储文件。一开始看起来就像是一个流浪角色。 SQL 并不是世界各地的标准,MySQL 导入程序期望 MySQL 友好的 SQL。我敢打赌你们的出口商做了一些奇怪的事情。
您可能需要稍微修改该文件才能使其与 MySQL 一起工作。
Check your dump file. Looks like a stray character at the beginning. SQL isn't standard the world around, and the MySQL importer expects MySQL-friendly SQL. I'm willing to bet that your exporter did something funky.
You may have to massage the file a bit to get it to work with MySQL.
我曾经遇到过这个问题 - 对我来说,删除转储文件开头的所有注释掉的行就可以解决问题。看起来这是一个空格错误。
I ran into this once - for me, deleting all the commented out lines at the beginning of my dump file is what fixed the problem. Looks like it was a whitespace error.
终于得到了解决方案。
第一个 .sql 文件转换为 UTF8。
然后使用这个命令
---root 是用户名
---test 是数据库名
或者
---root 是用户名
---test 是数据库名
Finally got a solution.
First .sql file converts into the UTF8.
Then use this command
---root is the username
---test is the database name
or
---root is the username
---test is the database name
这是我的情况:
End of file.sql without error:添加
'
之前);
我忘记在
);
End of file.sql with error:End of file.sql with error: End of file.sql without error:
This was my case:
I forgot to add
'
before);
End of file.sql with error:
End of file.sql without error:
如果错误之前的行包含
COMMENT ''
,请填充脚本中的注释或删除空注释定义。我在 MySQL Workbench 生成的脚本中发现了这一点。If the line before your error contains
COMMENT ''
either populate the comment in the script or remove the empty comment definition. I've found this in scripts generated by MySQL Workbench.我收到这个错误
,因为下载的 .sql.tar 文件因某种原因损坏。再次下载并解压就解决了这个问题。
I got this error
because the downloaded .sql.tar file was somehow corrupted. Downloading and extracting it again solved the issue.
在查询中进行以下更改解决了此问题:
请注意,列名称包含在`(选项卡上方的字符)中,而不是引号中。
Making the following changes in query solved this issue:
Note that the column names are enclosed in ` (character above tab) and not in quotes.
面临同样的问题。事实上,文件开头的 SQL 是错误的,因为在转储时我做了:
在文件开头写了 stdout 中的内容:
导致恢复引发该错误。
因此,删除 SQL 转储的第一行可以实现正确的恢复。
查看原始问题中恢复的完成方式,很可能转储的完成方式与我的类似,导致在 SQL 文件中打印标准输出警告(如果当时 mysqldump 正在打印它)。
Faced the same issue. Indeed it was wrong SQL at the beginning of the file because when dumping I did:
Which wrote at the beginning of the file something that was in stdout which was:
Resulting in the restore raising that error.
So deleting the first line of the SQL dump enables a proper restore.
Looking at the way the restore was done in the original question, there is a high chance the dump was done similarly as mine, causing a stdout warning printing in the SQL file (if ever mysqldump was printing it back then).
当您使用
mysqldump
转储文件时,请使用--result-file
选项而不是>
运算符。通过使用
>
,输出文件将以UTF-16
编码保存,即使您提供例如--default-character-set=utf8mb4
> 选项。不知何故,mysql
无法正确处理此编码当您使用
mysql
恢复数据库时,您可以使用<
加载文件When you use
mysqldump
to dump file use--result-file
option instead of>
operator.By using
>
, the output file will be saved inUTF-16
encoding even if you provide e.g--default-character-set=utf8mb4
option. Somehow this encoding can't be correctly handled bymysql
When you use
mysql
to restore the database you can use<
to load the file这个错误很常见。发生此错误的主要原因是:当用户意外编辑或错误编辑.sql文件时。
This error is very common. The main reason of the occurrence of this error is: When user accidentally edited or false edit the .sql file.
(对于那些通过搜索引擎提出此问题的人),请检查您的存储过程是否声明了自定义分隔符,因为当引擎无法弄清楚如何终止语句时,您可能会看到以下错误:
如果您有数据库转储并看到:
尝试使用自定义
DELIMITER
进行包装:(For those coming to this question from a search engine), check that your stored procedures declare a custom delimiter, as this is the error that you might see when the engine can't figure out how to terminate a statement:
If you have a database dump and see:
Try wrapping with a custom
DELIMITER
:您是否像这样选择了特定的数据库:
除此之外,我想不出此错误的任何原因。
Do you have a specific database selected like so:
Except for that I can't think of any reason for this error.
对我来说,我有一个
并且忘记了最后的分号。
所以看起来这个错误可能是在简单的语法错误之后发生的。就像它说的那样......我猜你永远无法足够仔细地阅读有用的编译器注释。
For me I had a
and forgot the semicolon at the end.
So looks like this error can occur after simple syntax errors. Just like it says.. I guess you can never read the helpful compiler comments closely enough.
由于使用 mysql/mariadb 保留字,我遇到了此错误:
INSERT INTO tablename ( precision) VALUE (2)
应该是
INSERT INTO tablename (` precision`) VALUE (2)
>I had this error because of using mysql/mariadb reserved words:
INSERT INTO tablename (precision) VALUE (2)
should be
INSERT INTO tablename (`precision`) VALUE (2)
我有这个,它是创建语法,更改为--create-options,生活变得更好
而且恢复得很好。
I had this, and it was the create syntax, changed to --create-options and life was better
And that restored nicely.