php 为 WORDPRESS 导入表时出错(位置 25 处的“ON”附近)(外键错误)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33974492/
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
Error (near "ON" at position 25) while importing Table for WORDPRESS ( A foreign key Error)
提问by Chetan Soni
I try to import a large file to my Database (WordPress), it shows some error like this:
我尝试将一个大文件导入我的数据库 (WordPress),它显示了一些错误,如下所示:
Error
Static analysis:
1 errors were found during analysis.
Unrecognized keyword. (near "ON" at position 25)
SQL query: Edit Edit
SET FOREIGN_KEY_CHECKS = ON;
MySQL said: Documentation
#2006 - MySQL server has gone away
回答by candle
I had the same error when I tried to migrate Drupal database to a new local apache server(I am using XAMPP on Windows machine). Actually I don't know the meaning of this error, but after trying steps below, I imported the database without errors. Hope this could help:
当我尝试将 Drupal 数据库迁移到新的本地 apache 服务器时,我遇到了同样的错误(我在 Windows 机器上使用 XAMPP)。其实我不知道这个错误的含义,但是在尝试了下面的步骤之后,我没有错误地导入了数据库。希望这可以帮助:
Changing php.ini at C:\xampp\php\php.ini
在 C:\xampp\php\php.ini 更改 php.ini
max_execution_time = 600
max_input_time = 600
memory_limit = 1024M
post_max_size = 1024M
Changing my.ini at C:\xampp\mysql\bin\my.ini
在 C:\xampp\mysql\bin\my.ini 更改 my.ini
max_allowed_packet = 1024M
回答by Santosh Kumar Sahu
- Goto XAMPP control panel>
- Stop Apache and MySql services>
Click on Config of Apache>select php.ini and change the followings:
max_execution_time = 600
max_input_time = 600
memory_limit = 1024M
post_max_size = 1024M
Click on Config button of MySql and select my.ini and change:
max_allowed_packet = 1024M
- Again Start the services and try.. i hope it will work.
- 转到 XAMPP 控制面板>
- 停止 Apache 和 MySql 服务>
单击 Apache 的配置>选择 php.ini 并更改以下内容:
max_execution_time = 600
max_input_time = 600
memory_limit = 1024M
post_max_size = 1024M
单击 MySql 的 Config 按钮,选择 my.ini 并更改:
max_allowed_packet = 1024M
- 再次启动服务并尝试.. 我希望它会起作用。
回答by Adrian Vignolo
Just specifying the above answer from Candle.
只需从 Candle 中指定上述答案即可。
You will need to adjust only one line in my.ini:
您只需要在 my.ini 中调整一行:
Changing my.ini at C:\xampp\mysql\bin\my.ini OR click on config of XAMP>select php.ini and change the following:
max_allowed_packet = 50M // the value depends on the size of the .sql files you are trying upload.
在 C:\xampp\mysql\bin\my.ini 更改 my.ini 或单击 XAMP 的配置>选择 php.ini 并更改以下内容:
max_allowed_packet = 50M // the value depends on the size of the .sql files you are trying upload.
回答by pixelkicks
I had the same problem when trying to import a Wordpess MySQL dump to a new server. In the end after an hour debugging I had to manually remove the following tables from the .sql file:
我在尝试将 Wordpess MySQL 转储导入新服务器时遇到了同样的问题。最后经过一个小时的调试,我不得不从 .sql 文件中手动删除以下表:
wp_cf7dbplugin_st wp_cf7dbplugin_submits
wp_cf7dbplugin_st wp_cf7dbplugin_submits
There were some really large values (possibly PDF files) stored in some of the fields which were causing a problem.
在某些导致问题的字段中存储了一些非常大的值(可能是 PDF 文件)。
Imported fine after I removed the tables from the script.
从脚本中删除表后导入正常。
回答by kiko carisse
For me my main goal was to make a stage site for my wordpress site, which had wordfence on it.
对我来说,我的主要目标是为我的 wordpress 网站制作一个舞台网站,上面有 wordfence。
I was using plesk obsidian and had to update mariadb to get past the error in the main question here Error (near “ON” at position 25) while importing Table for WORDPRESS ( A foreign key Error)
which I was able to do by reading this blog article - https://support.plesk.com/hc/en-us/articles/213403429-How-to-upgrade-MySQL-5-5-to-5-6-5-7-or-MariaDB-5-5-to-10-0-10-1-10-2-on-Linux-
我正在使用 plesk obsidian 并且不得不更新 mariadb 以解决主要问题中的错误Error (near “ON” at position 25) while importing Table for WORDPRESS ( A foreign key Error)
,我可以通过阅读这篇博客文章来解决这个问题 - https://support.plesk.com/hc/en-us/articles/ 213403429-How-to-upgrade-MySQL-5-5-to-5-6-5-7-or-MariaDB-5-5-to-10-0-10-1-10-2-on-Linux-
That took forever but got me passed the above error, but then I was getting this error on db import:
这花了很长时间,但让我通过了上述错误,但后来我在 db import 时遇到了这个错误:
#1062 - Duplicate entry '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xEF\xBF\xBD\xEF\xBF\xBD' for key 'PRIMARY' when find and replace domain on wordfence
#1062 - Duplicate entry '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xEF\xBF\xBD\xEF\xBF\xBD' for key 'PRIMARY' when find and replace domain on wordfence
I was doing the domain find and replace in vscode "mydomain.com" with "stage.mydomain.com". The problem turned out to be that wordfence saves binary data or something to the database, and just opening it in vscode and saving it was altering that somehow, and thus throwing obscure duplicate entry error for primary key
我正在做域查找并在 vscode 中用“stage.mydomain.com”替换“mydomain.com”。问题原来是 wordfence 将二进制数据或其他东西保存到数据库中,只需在 vscode 中打开它并保存它就会以某种方式改变它,从而导致模糊duplicate entry error for primary key
The fix for the above was to not open, or alter, the .sql file in vscode but to do the find in replace with linux. This was the commands I ran to do this on Mac -
解决上述问题的方法是不打开或更改 vscode 中的 .sql 文件,而是使用 linux 进行查找。这是我在 Mac 上运行的命令 -
find and replace http: with https: -
找到并替换 http: 与 https: -
perl -pi -w -e 's/http:\/\/mydomain.com/https:\/\/mydomain.com/g;' my_db_file.sql
perl -pi -w -e 's/http:\/\/mydomain.com/https:\/\/mydomain.com/g;' my_db_file.sql
find and replace mydomain.com with stage.mydomain.com -
找到并用 stage.mydomain.com 替换 mydomain.com -
perl -pi -w -e 's/mydomain.com/stage.mydomain.com/g;' my_db_file.sql
perl -pi -w -e 's/mydomain.com/stage.mydomain.com/g;' my_db_file.sql