gpt4 book ai didi

php - key 1 的重复条目 1 - 无重复项

转载 作者:行者123 更新时间:2023-11-30 00:39:58 25 4
gpt4 key购买 nike

您好,我正在尝试将数据库导入到事件服务器,但我不断收到此错误消息:

SQL查询:

--
-- Dumping data for table `wp_2_comments`
--
INSERT INTO `wp_2_comments` ( `comment_ID` , `comment_post_ID` , `comment_author` , `comment_author_email` , `comment_author_url` , `comment_author_IP` , `comment_date` , `comment_date_gmt` , `comment_content` , `comment_karma` , `comment_approved` , `comment_agent` , `comment_type` , `comment_parent` , `user_id` )
VALUES ( 1, 1, 'Mr WordPress', '', 'http://www.kbee.co.za/', '', '2013-12-22 17:34:17', '2013-12-22 17:34:17', 'Hi, this is a comment.\nTo delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.', 0, '1', '', '', 0, 0 ) ;

MySQL 说:文档

1062 - 键 1 的重复条目“1”

下面是该特定表的结构:

--
-- Table structure for table `wp_2_comments`
--

CREATE TABLE IF NOT EXISTS `wp_2_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',
PRIMARY KEY (`comment_ID`),
KEY `comment_post_ID` (`comment_post_ID`),
KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`),
KEY `comment_date_gmt` (`comment_date_gmt`),
KEY `comment_parent` (`comment_parent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `wp_2_comments`
--

INSERT INTO `wp_2_comments` (`comment_ID`, `comment_post_ID`, `comment_author`, `comment_author_email`, `comment_author_url`, `comment_author_IP`, `comment_date`, `comment_date_gmt`, `comment_content`, `comment_karma`, `comment_approved`, `comment_agent`, `comment_type`, `comment_parent`, `user_id`) VALUES
(1, 1, 'Mr WordPress', '', 'http://www.kbee.co.za', '', '2013-12-22 17:34:17', '2013-12-22 17:34:17', 'Hi, this is a comment.\nTo delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.', 0, '1', '', '', 0, 0);

从我在其他主题中看到的情况来看,这可能是因为表正在重复,或者主键字段没有自动递增。表中的结构将主键字段设置为自动增量,我已经尝试删除该特定表并尝试再次导入,但我没有找到任何乐趣。

最佳答案

对于自动增量值,即使删除值为 1 的行,自动增量 col 的下一个值也将是 2 而不是 1。因此使用截断表

截断 wp_2_comments

然后尝试插入将从 1 开始计数的值。

也改变这个

 ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

 ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

首先执行此查询

CREATE TABLE IF NOT EXISTS `wp_2_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',
PRIMARY KEY (`comment_ID`),
KEY `comment_post_ID` (`comment_post_ID`),
KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`),
KEY `comment_date_gmt` (`comment_date_gmt`),
KEY `comment_parent` (`comment_parent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

然后执行这个查询

truncate wp_2_comments

关于php - key 1 的重复条目 1 - 无重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21849027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com