PhpMyAdmin export / import results in a double primary key error

I want to globally replace all instances of the URL of my site in the Wordpress MySQL database with the new site URL. To do this, I use phpMyAdmin to export the database to a .sql file, and then do a global replacement in a text editor, and then use phpMyAdmin to import the .sql file.

During import, I encounter a duplicate entry for a primary key error. Trying to debug this, I exported the file, then imported the identical file without making any changes, and I still get the same error.

I appreciate any help in resolving this issue.

--
-- 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/', '', '2011-04-28 00:49:55', '2011-04-28 00:49:55'
       ,'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, 'post-trashed',  '',  '', 0, 0 ) ;

MySQL said: 

#1062 - Duplicate entry '1' for key 'PRIMARY' 
+3
source share
8 answers

The source data is still in the database.

, UPDATE, INSERT , , , .

DELETE FROM `tblName`;

.

+6

, , . , PRIMARY KEY, UNIQUE, .

. . PHPMyAdmin . 1, , . X, .

SQL, .

DELETE FROM `wp_comments` WHERE `comment_ID` = 1 LIMIT 1

PHPMyAdmin SQL .

+2

. , , .

+1

- , - - :

, *THE_NAME_OF_YOUR_DB* latin1 COLLATE latin1_general_ci; USE *THE_NAME_OF_YOUR_DB*;

, - - , , !! () !

+1

, UPDATE INSERT. phpMyAdmin :

  • .
  • . "" , . , . , , . , .
  • "".
  • " :" "".
  • . , 2 , " ():" " ", , .
  • " "    ", ": ""   ( "INSERT" ).
  • "".
  • SQL.
  • ! , - .
  • , , . .
  • phpMyAdmin "".
  • " :" " "   . GO

! , , ( 2). , .

+1

, , . .

  UPDATE `wp_comments` 
  SET 'comment_author_url' = 'YOUR NEW ADDRESS'
  WHERE  `comment_ID` = 1

, . , "WHERE" comment_author_url '=' YOUR OLD ADDRESS '"

0

, , URL, , , :

Update `wp_comments` Set 
`comment_author_url` = 'http://wordpress.org/'
Where `comment_author` = 'Mr WordPress'

SQL PHPMyAdmin SQL .

. , . , :)

0

INSERT .... (what you already have) 
ON DUPLICATE KEY UPDATE;

, .

0

All Articles