MySQL SQL 错误 1064 - 导入错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19004101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL Error 1064 - Import Error
提问by 210 USA
I exported a database as a backup that was working fine. When I imported the database to the same exact server, folder, etc. I got this error:
我导出了一个数据库作为备份,运行良好。当我将数据库导入到相同的服务器、文件夹等时,我收到了这个错误:
There is a chance that you may have found a bug in the SQL parser. Please examine your query closely, and check that the quotes are correct and not mis-matched. Other possible failure causes may be that you are uploading a file with binary outside of a quoted text area. You can also try your query on the MySQL command line interface. The MySQL server error output below, if there is any, may also help you in diagnosing the problem. If you still have problems or if the parser fails where the command line interface succeeds, please reduce your SQL query input to the single query that causes problems, and submit a bug report with the data chunk in the CUT section below: ----BEGIN CUT---- eNo1jUEKwjAURIXu/inmADHkpwYxu1JCu0iTmFQ9gYtushP09qaCs3oMjxmXc8wWI2PU8C5YMDSY qayt7oiWT7l6CyON7NWxV5LpVjJiERgmF1aBu2vmY6sY5xwX11Ql9YXSMlicGhtKc9otEcs+1Es+ w2/19SY/hMniWen3Qd3hny8nMiDI ----END CUT---- ----BEGIN RAW---- ERROR: C1 C2 LEN: 1 2 11 STR:
MySQL: 5.5.30-30.1 USR OS, AGENT, VER: Win CHROME 5.0.29 PMA: 4.0.5 PHP VER,OS: 5.3.17 Linux LANG: en SQL:
----END RAW----SQL query:
MySQL said: Documentation
#1064 - 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 '' at line 1
您有可能在 SQL 解析器中发现了错误。请仔细检查您的查询,并检查报价是否正确且没有错误匹配。其他可能的失败原因可能是您正在上传带引号的文本区域之外的二进制文件。您还可以在 MySQL 命令行界面上尝试查询。下面的 MySQL 服务器错误输出,如果有的话,也可以帮助您诊断问题。如果您仍然有问题,或者如果解析器在命令行界面成功时失败,请将您的 SQL 查询输入减少到导致问题的单个查询,并在下面的 CUT 部分提交包含数据块的错误报告:
MySQL:5.5.30-30.1 USR OS,代理,VER:Win CHROME 5.0.29 PMA:4.0.5 PHP VER,OS:5.3.17 Linux LANG:en SQL:
----END RAW----SQL查询:
MySQL 说: 文档
#1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以了解要在第 1 行的 '' 附近使用的正确语法
The only problem seems to be that my index page is missing content, the main content actually. All of these files are .sql.
唯一的问题似乎是我的索引页缺少内容,实际上是主要内容。所有这些文件都是 .sql。
I then dropped all my tables and imported the original database from April of last year. Obviously, this database is missing all the account info, order info, etc. for all my customers as well as all the changes that have been made to my products.
然后我删除了所有表并从去年 4 月导入了原始数据库。显然,这个数据库缺少我所有客户的所有帐户信息、订单信息等,以及对我的产品所做的所有更改。
When I compare the two databases the first 11 lines seem to be the problem but I don't know how to fix it. The first 11 lines of the file that DO NOT WORK are:
当我比较两个数据库时,前 11 行似乎是问题所在,但我不知道如何解决。文件的前 11 行不工作是:
-- phpMyAdmin SQL Dump
-- version 4.0.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 22, 2013 at 01:28 PM
-- Server version: 5.5.30-30.1
-- PHP Version: 5.3.17
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
The first 11 lines of the file that DOES WORK are:
文件的前 11 行是:
-- phpMyAdmin SQL Dump
-- version 3.4.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 09, 2012 at 05:50 AM
-- Server version: 5.1.61
-- PHP Version: 5.2.17
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
I hve tried to simply copy and paste the 11 lines from the working file to the file that does not work and get another error.
我试图简单地将工作文件中的 11 行复制并粘贴到不起作用的文件中,并得到另一个错误。
I know this is a long post and I apologize but I have been struggling with this for hours and really need some help.
我知道这是一篇很长的文章,我深表歉意,但我已经为此苦苦挣扎了几个小时,真的需要一些帮助。
Thanks
谢谢
回答by 210 USA
OK, so here is what I found, finally. When I opened the file that was giving me the error in notebook+, the last line, of course, had the following:
好的,这就是我最后发现的。当我打开在 notebook+ 中给我错误的文件时,当然,最后一行有以下内容:
ETXNULNULNULNULNULNULNULNULNUL
ETXNULNULNULNULNULNULNULNUL
The original working database when opened did not have any of these characters.
打开时的原始工作数据库没有任何这些字符。
When I simply deleted the last row of the file that was giving me the error and imported the database, everything worked fine. However, my homepage was still not being pulled up properly. I applied a workaround for now and will try to figure that out later.
当我简单地删除给我错误的文件的最后一行并导入数据库时,一切正常。但是,我的主页仍然没有被正确拉起。我现在应用了一个解决方法,稍后会尝试解决这个问题。
I hope this helps someone.
我希望这可以帮助别人。
回答by Erika
I had the same problem when exporting my database for a Joomla 2.5 site. It has something to do with the compression in phpmyadmin. I changed the compression from "none" to "zipped" before exporting the database and that solved it.
我在为 Joomla 2.5 站点导出数据库时遇到了同样的问题。它与phpmyadmin中的压缩有关。在导出数据库之前,我将压缩从“无”更改为“压缩”并解决了它。
Hope that helps!
希望有帮助!
回答by PiotrK
In my case I need to change compression to NONEand SQL compatibility mode to ANSI. I was exporting WordPress database to the another server.
在我的情况下,我需要将压缩更改为NONE并将 SQL 兼容模式更改为ANSI。我正在将 WordPress 数据库导出到另一台服务器。
回答by momo
As it seems there are a bunch o reasons that could trigger this error. I just wanted to share my problem and the workaround i found for it, hopefully it would save someone some time. I too encountered this problem while trying to import a database to MySql. I had exported a version of a database from my local machine and i wanted to import it to the server where my website is hosted. problem was that there was a mismatch between the versions of the two systems. I managed to get around the problem by using the compatibility option(both while exporting and while importing). i used "MYSQL323" . This fixed my problem. I think this is a good solution for those who have the possibility to make a fresh exported version of the database.
似乎有很多原因可能会触发此错误。我只是想分享我的问题和我找到的解决方法,希望它能节省一些时间。我在尝试将数据库导入 MySql 时也遇到了这个问题。我从本地机器导出了一个数据库版本,我想将它导入到托管我的网站的服务器。问题是两个系统的版本不匹配。我设法通过使用兼容性选项(在导出和导入时)解决了这个问题。我使用了“MYSQL323”。这解决了我的问题。我认为对于那些有可能制作新的数据库导出版本的人来说,这是一个很好的解决方案。
回答by user3185830
I`ve fixed this error 1 minute before. When you export sql.gz file, try to extract it. The extracted file is still compressed bu *.sql file. Try add again *.sql.gz And import the renamed file. it will work.
我已经在 1 分钟前修复了这个错误。导出 sql.gz 文件时,请尝试将其解压缩。解压出来的文件仍然是压缩过的 *.sql 文件。再次尝试添加 *.sql.gz 并导入重命名的文件。它会起作用。
What i`m trying to say, that phpMyAdmin compress the file twice.
我想说的是,phpMyAdmin 将文件压缩了两次。
回答by smileface
My solution was: comment
我的解决方案是:评论
;mbstring.func_overload = 2
in /etc/php5/apache2/php.ini
在 /etc/php5/apache2/php.ini
回答by RomanL
It's a bug in phpMyadmin
这是 phpMyadmin 中的一个错误
Here is a temporary fix
这是一个临时修复
http://sourceforge.net/p/phpmyadmin/bugs/4095/#7e0c
http://sourceforge.net/p/phpmyadmin/bugs/4095/#7e0c
or something like that:
或类似的东西:
replace "PMA_Response::getInstance()->disable();" "//PMA_Response::getInstance()->disable();" -- /path_to_phpMyAdmin/export.php
替换“PMA_Response::getInstance()->disable();” "//PMA_Response::getInstance()->disable();" -- /path_to_phpMyAdmin/export.php
回答by Antonio
I had the same problem importing a CSV file and figured out that the issue was that i had some empty columns from excel conversion and when i selected the first line as column names to import, it tried to create several columns without apropriate unique name.
我在导入 CSV 文件时遇到了同样的问题,并发现问题是我有一些来自 excel 转换的空列,当我选择第一行作为要导入的列名时,它试图创建几个没有适当唯一名称的列。
回答by Saif
I had a blank line at the end of the dump file. Removing the line fixed my issue.
我在转储文件的末尾有一个空行。删除该行解决了我的问题。