gpt4 book ai didi

mysql - 错误 : #1062 - Duplicate entry '1' for key 'PRIMARY'

转载 作者:行者123 更新时间:2023-11-29 01:03:28 24 4
gpt4 key购买 nike

我已获得要上传到我的服务器的数据库文件,但在导入时收到以下错误消息。我已经搜索过其他类似的问题,但无法解决这个问题。

SQL查询:

--
-- Dumping data for table `wp_comments`
--

INSERT INTO `wp_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://wordpress.org/',
'',
'0000-00-00 00:00:00',
'0000-00-00 00:00:00',
'Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.',
0,
'1',
'',
'',
0,
0
);

MySQL 说:

#1062 - Duplicate entry '1' for key 'PRIMARY'

最佳答案

wp_comments 表中的 comment_ID 列设置为主键,因此不允许将具有相同 comment_ID 值的多个记录插入到表中。

在您的情况下,您已经插入了一条值为“1”的记录,因此您必须手动删除该记录(或清空整个表),或者从不同的 comment_ID 开始插入,或者只是省略 comment_ID 列和值,它很可能会自动填充。

将您的查询重新格式化为如下所示:

INSERT INTO wp_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 ( null, 1, 'Mr WordPress', '', 'http:////wordpress.org//', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', "Hi, this is a comment. To 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 ) ;

comment_ID 的值为null,或者

INSERT INTO wp_comments ( 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, 'Mr WordPress', '', 'http:////wordpress.org//', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', "Hi, this is a comment. To 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 ) ;

完全省略了 comment_ID 及其值。

在这两种情况下,MySQL 都会自动分配下一个自动递增的值。

关于mysql - 错误 : #1062 - Duplicate entry '1' for key 'PRIMARY' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21112831/

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