简体   繁体   English

导入WordPress数据库 - #1075 - 表定义不正确;只能有一个自动列,必须将其定义为键

[英]Importing WordPress Database - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

I'm trying to move a WordPress database from Plesk to cPanel using phpMyAdmin but I get the following error when importing: 我正在尝试使用phpMyAdmin将WordPress数据库从Plesk移动到cPanel,但导入时出现以下错误:

SQL query:

Table structure for table `wp_commentmeta`

CREATE TABLE IF NOT EXISTS  `wp_commentmeta` (

 `meta_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
 `comment_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT  '0',
 `meta_key` VARCHAR( 255 ) DEFAULT NULL ,
 `meta_value` LONGTEXT
) ENGINE = MYISAM AUTO_INCREMENT =236 DEFAULT CHARSET = utf8;

MySQL said: Documentation

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

I exported the database using the quick option as I normally do then just did a normal import. 我像往常一样使用快速选项导出数据库,然后进行正常导入。

The relevant part of the sql export is: sql导出的相关部分是:

--
-- Table structure for table `wp_commentmeta`
--

CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL auto_increment,
  `comment_id` bigint(20) unsigned NOT NULL default '0',
  `meta_key` varchar(255) default NULL,
  `meta_value` longtext
) ENGINE=MyISAM AUTO_INCREMENT=236 DEFAULT CHARSET=utf8;

So I tried a solution mentioned on Google 所以我尝试了在Google上提到的解决方案

CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL PRIMARY KEY auto_increment,
  `comment_id` bigint(20) unsigned NOT NULL default '0',
  `meta_key` varchar(255) default NULL,
  `meta_value` longtext
) ENGINE=MyISAM AUTO_INCREMENT=236 DEFAULT CHARSET=utf8;

And this time I got this error: 而这次我收到了这个错误:

SQL query:

CREATE TABLE IF NOT EXISTS  `wp_comments` (

 `comment_ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
 `comment_post_ID` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT  '0',
 `comment_author` TINYTEXT NOT NULL ,
 `comment_author_email` VARCHAR( 100 ) NOT NULL DEFAULT  '',
 `comment_author_url` VARCHAR( 200 ) NOT NULL DEFAULT  '',
 `comment_author_IP` VARCHAR( 100 ) NOT NULL DEFAULT  '',
 `comment_date` DATETIME NOT NULL DEFAULT  '0000-00-00 00:00:00',
 `comment_date_gmt` DATETIME NOT NULL DEFAULT  '0000-00-00 00:00:00',
 `comment_content` TEXT NOT NULL ,
 `comment_karma` INT( 11 ) NOT NULL DEFAULT  '0',
 `comment_approved` VARCHAR( 20 ) NOT NULL DEFAULT  '1',
 `comment_agent` VARCHAR( 255 ) NOT NULL DEFAULT  '',
 `comment_type` VARCHAR( 20 ) NOT NULL DEFAULT  '',
 `comment_parent` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT  '0',
 `user_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT  '0'
) ENGINE = MYISAM AUTO_INCREMENT =226 DEFAULT CHARSET = utf8;

MySQL said: Documentation

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key 

The CREATE section for wp_comments is as follows. wp_comments的CREATE部分如下所示。

DROP TABLE IF EXISTS `wp_comments`;
CREATE TABLE IF NOT EXISTS `wp_comments` (
  `comment_ID` bigint(20) unsigned NOT NULL auto_increment,
  `comment_post_ID` bigint(20) unsigned NOT NULL default '0',
  `comment_author` tinytext NOT NULL,
  `comment_author_email` varchar(100) NOT NULL default '',
  `comment_author_url` varchar(200) NOT NULL default '',
  `comment_author_IP` varchar(100) NOT NULL default '',
  `comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
  `comment_content` text NOT NULL,
  `comment_karma` int(11) NOT NULL default '0',
  `comment_approved` varchar(20) NOT NULL default '1',
  `comment_agent` varchar(255) NOT NULL default '',
  `comment_type` varchar(20) NOT NULL default '',
  `comment_parent` bigint(20) unsigned NOT NULL default '0',
  `user_id` bigint(20) unsigned NOT NULL default '0'
) ENGINE=MyISAM AUTO_INCREMENT=226 DEFAULT CHARSET=utf8;

At the bottom of the dump is the following auto_increment information. 在转储的底部是以下auto_increment信息。

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `wp_commentmeta`
--
ALTER TABLE `wp_commentmeta`
AUTO_INCREMENT=236;
--
-- AUTO_INCREMENT for table `wp_comments`
--
ALTER TABLE `wp_comments`
AUTO_INCREMENT=226;
--
-- AUTO_INCREMENT for table `wp_event_list`
--
ALTER TABLE `wp_event_list`
AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `wp_layerslider`
--
ALTER TABLE `wp_layerslider`
AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `wp_options`
--
ALTER TABLE `wp_options`
AUTO_INCREMENT=497473;
--
-- AUTO_INCREMENT for table `wp_postmeta`
--
ALTER TABLE `wp_postmeta`
AUTO_INCREMENT=18312;
--
-- AUTO_INCREMENT for table `wp_posts`
--
ALTER TABLE `wp_posts`
AUTO_INCREMENT=2083;
--
-- AUTO_INCREMENT for table `wp_terms`
--
ALTER TABLE `wp_terms`
AUTO_INCREMENT=136;
--
-- AUTO_INCREMENT for table `wp_term_taxonomy`
--
ALTER TABLE `wp_term_taxonomy`
AUTO_INCREMENT=137;
--
-- AUTO_INCREMENT for table `wp_usermeta`
--
ALTER TABLE `wp_usermeta`
AUTO_INCREMENT=1527;
--
-- AUTO_INCREMENT for table `wp_users`
--
ALTER TABLE `wp_users`
AUTO_INCREMENT=43;
--
-- AUTO_INCREMENT for table `wp_woocommerce_attribute_taxonomies`
--
ALTER TABLE `wp_woocommerce_attribute_taxonomies`
AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `wp_woocommerce_order_itemmeta`
--
ALTER TABLE `wp_woocommerce_order_itemmeta`
AUTO_INCREMENT=1869;
--
-- AUTO_INCREMENT for table `wp_woocommerce_order_items`
--
ALTER TABLE `wp_woocommerce_order_items`
AUTO_INCREMENT=294;
--
-- AUTO_INCREMENT for table `wp_woocommerce_tax_rates`
--
ALTER TABLE `wp_woocommerce_tax_rates`
AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `wp_woocommerce_termmeta`
--
ALTER TABLE `wp_woocommerce_termmeta`
AUTO_INCREMENT=116;

And this is where I'm really stuck as I've rapidly and suddenly reached the limit of my knowledge and don't want to make matters worse. 这就是我真正被困住的地方,因为我很快就突然达到了我的知识极限并且不想让事情变得更糟。 I'm used to seeing the info in the alter table section within the create and don't know id I should be copying it into the create sections or what. 我习惯于在create table中看到alter table部分中的信息并且不知道id我应该将它复制到创建部分或者什么。

Can someone please provide some hints as to why this is occurring. 有人可以提供一些提示,说明为什么会这样。

Thanks. 谢谢。

Possible that you are using two different versions of phpmyadmin, one in plesk, the other one in your cpanel system? 您可能正在使用两个不同版本的phpmyadmin,一个在plesk中,另一个在您的cpanel系统中?

You could try 'Adminer', which is a powerful phpmyadmin alternative and it is based on only one single file! 您可以尝试'Adminer',这是一个功能强大的phpmyadmin替代方案,它只基于一个文件!

Download it from here: http://www.adminer.org/en/ 从这里下载: http//www.adminer.org/en/

Copy adminer.php to the server where you want to get the export from and to the one where you want to import the sql data. 将adminer.php复制到要从中导出sql数据的服务器和要导出的服务器。

Go to your website/adminer.php and login to your db with the credentials you have. 转到您的网站/ adminer.php并使用您拥有的凭据登录您的数据库。 The Export and import is similar to phpmyadmin but the advantage is that you are using one common version of the adminer software which makes sure that import and export is gonna be run fine. 导出和导入类似于phpmyadmin,但优点是您使用的是一个常用版本的adminer软件,可确保导入和导出运行正常。

For each Wordpress table, add its key in this way (see the penultimate line): 对于每个Wordpress表,以这种方式添加其键(参见倒数第二行):

CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL auto_increment,
  `comment_id` bigint(20) unsigned NOT NULL default '0',
  `meta_key` varchar(255) default NULL,
  `meta_value` longtext,
  key (meta_id) -- add this line (remember to add the comma in the previous line)
) ENGINE=MyISAM AUTO_INCREMENT=236 DEFAULT CHARSET=utf8;

Wordpress tables: Wordpress表:

wp_commentmeta
wp_comments
wp_links
wp_options
wp_postmeta
wp_posts
wp_terms
wp_term_relationships
wp_term_taxonomy
wp_usermeta
wp_users

I have the same problem when I export from another phpMyAdmin, the file mysql export does not include primary key in there, then when exporting I choosed method "Custom - display all possible options" , then I checked "IF NOT EXISTS (less efficient as indexes will be generated during table creation)" . 当我从另一个phpMyAdmin导出时,我有同样的问题,文件mysql导出不包含主键,然后在导出我选择的方法“自定义 - 显示所有可能的选项” ,然后我检查“如果不存在(效率较低)在表创建期间将生成索引)“ And then the exported file included primary key in the file. 然后导出的文件包含文件中的主键。 And my problem is solved. 我的问题解决了。 I hope this help you. 我希望这对你有帮助。

This problem is documented by phpMyAdmin (PMA) and "fixed" by essentially saying that you can't use the current version with MySQL 5.0. 这个问题由phpMyAdmin(PMA)记录并且通过基本上说你不能在MySQL 5.0中使用当前版本来“修复”。

Table export with auto_increment, primary key creates invalid statements > Problems due to missing enforcement of the minimum supported MySQL version 使用auto_increment进行表导出,主键创建无效语句>由于缺少最低支持的MySQL版本的实施而导致的问题

Found out my server is running PMA 4.3 with MYSQL 5.0.95 whereas my local is MYSQL 5.5. 发现我的服务器运行PMA 4.3与MYSQL 5.0.95,而我的本地是MYSQL 5.5。 I don't know why this is a problem now, as older PMA would import/export beautifully as mysqldump, I guess they changed and simplified the syntax for performances reasons which is legit. 我现在不知道为什么这是一个问题,因为旧的PMA会像mysqldump那样导入/导出很好,我猜他们改变并简化了语法,因为这是合法的表演原因。

If you're like me, you exported your tables from MySQL 5.5 (hosting server) and tried to import into MySQL 5.6 (XAMPP on Mac) and you got the dreaded 1075 error. 如果你像我一样,你从MySQL 5.5(托管服务器)导出你的表并尝试导入MySQL 5.6(Mac上的XAMPP),你得到了可怕的1075错误。 After searching on the Internet for hours you found out it has something to do with the Auto-increment and Primary key. 在互联网上搜索了几个小时后,你发现它与自动增量和主键有关。 Not being a database programmer, this information (provided in links by liquified, above) does not help solve the problem as you're basically told: "Hey, don't do that". 不是数据库程序员,这些信息(由上面提到的链接提供)无助于解决问题,因为你基本上被告知:“嘿,不要这样做”。 Well mr. 先生,先生。 PMA bug, it's already done, so how do I fix it? PMA错误,它已经完成,所以我该如何解决?

Here's what worked for me: 这对我有用:

The SQL you exported has a bunch of statements near the bottom to "ALTER" all the tables you created at top. 您导出的SQL在底部附近有一堆语句“ALTER”您在顶部创建的所有表。 All you need to do is copy into the CREATE statement above. 您需要做的就是复制到上面的CREATE语句中。

So, at the bottom, your ALTER wp_commentmeta looks like this: 所以,在底部,你的ALTER wp_commentmeta看起来像这样:

ALTER TABLE `wp_commentmeta`
  ADD PRIMARY KEY  (`meta_id`),
  ADD KEY `comment_id` (`comment_id`),
  ADD KEY `meta_key` (`meta_key`);

And at the top, the CREATE looks like this: 在顶部,CREATE看起来像这样:

CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL auto_increment,
  `comment_id` bigint(20) unsigned NOT NULL default '0',
  `meta_key` varchar(255) default NULL,
  `meta_value` longtext
) TYPE=MyISAM AUTO_INCREMENT=67;

The solution is to remove the ALTER at bottom and put those statements into the CREATE, like this (adding the comma after the 'longtext'): 解决方案是删除底部的ALTER并将这些语句放入CREATE,就像这样(在'longtext'之后添加逗号):

CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL auto_increment,
  `comment_id` bigint(20) unsigned NOT NULL default '0',
  `meta_key` varchar(255) default NULL,
  `meta_value` longtext,
PRIMARY KEY (`meta_id`),
  KEY `comment_id` (`comment_id`),
  KEY `meta_key` (`meta_key`)
) TYPE=MyISAM AUTO_INCREMENT=67;

Now, if you use this, you'll get a 1064 error for bad syntax. 现在,如果你使用它,你会得到1064错误的语法错误。 Can a guy get a break? 一个人可以休息一下吗? You still need to change the MyISAM stuff for this new version: 您仍然需要更改此新版本的MyISAM内容:

TYPE=MyISAM AUTO_INCREMENT=67;

change to 改成

ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=67;

In the end your final CREATE declaration will look like this and you won't need any ALTER table statements at the bottom of your SQL: 最后,您的最终CREATE声明将如下所示,您不需要SQL底部的任何ALTER表语句:

CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL auto_increment,
  `comment_id` bigint(20) unsigned NOT NULL default '0',
  `meta_key` varchar(255) default NULL,
  `meta_value` longtext,
  PRIMARY KEY (`meta_id`),
  KEY `comment_id` (`comment_id`),
  KEY `meta_key` (`meta_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=50 ;

Yes, you have to manually edit your SQL if you plan on importing it into the new DB. 是的,如果您计划将SQL导入新数据库,则必须手动编辑SQL。 If you have a lot of tables and/or websites affected by this 'bug', it will take some time, so grab a coffee, whatever works, and fix it and move on with your life. 如果你有很多桌子和/或网站受到这个“虫子”的影响,那么它需要一些时间,所以你可以喝咖啡,无论做什么工作,然后解决它,继续你的生活。

Now, if you still get errors, check your syntax, make sure to remove 'ADD' when you copy from the ALTER table. 现在,如果仍然出现错误,请检查语法,确保从ALTER表复制时删除“ADD”。 Remove ';' 去掉 ';' and use commas correctly. 并正确使用逗号。 If you managed to import part of the DB, a few tables, but got snagged on syntax, DUMP all tables and try your import again once you've made the fix. 如果你设法导入了部分数据库,一些表,但是在语法上遇到了问题,请在所有表中使用DUMP,并在完成修复后再次尝试导入。 I encountered a 1062: duplicate primary key because I managed to import some tables and others failed. 我遇到了一个1062:重复主键,因为我设法导入了一些表而其他表失败了。 When I tried to import again, the primary key was already set for the table. 当我再次尝试导入时,已经为表设置了主键。

All this headache because of performance 'enhancements' in new PMA/MySQL. 由于新PMA / MySQL中的性能“增强”,所有这一切都令人头痛。 Humbug! 骗子!

暂无
暂无

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

相关问题 错误1075:错误的表格定义; 只能有一个自动列,并且必须将其定义为键 - ERROR 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key Phpmyadmin#1075-错误的表定义; 只能有一个自动列,并且必须将其定义为键 - Phpmyadmin #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key 错误1075:表定义不正确; 只能有一个自动列,它必须被定义为一个键(使用 gorm 和 mysql) - Error 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key (using gorm and mysql) ERROR 1075 表定义不正确; 只能有一个自动列,并且必须将其定义为键 - ERROR 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key MySQL-1075错误的表格定义,只能有一个自动列,必须将其定义为键 - MySQL - 1075 Incorrect table definition, there can be only one auto column and it must be defined as a key #1075-错误的表格定义; 只能有一个自动列,并且必须将其定义为键 - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key "<i>#1075 - Incorrect table definition;<\/i> #1075 - 表定义不正确;<\/b> <i>there can be only one auto column and it must be defined as a key<\/i>只能有一个自动列,并且必须将其定义为键<\/b>" - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key SQLSTATE[42000]:语法错误或访问冲突:1075 不正确的表定义; 只能有一个自动列,并且必须将其定义为键 - SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key Laravel foreign_key错误的表定义; 只能有一个自动列,并且必须将其定义为键 - Laravel foreign_key Incorrect table definition; there can be only one auto column and it must be defined as a key Laravel表定义错误; 只能有一个自动列,并且必须将其定义为键 - Laravel Incorrect table definition; there can be only one auto column and it must be defined as a key
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM