WordPress – How to use phpMyAdmin to Export and Import Comments To Another Website

by Elaine on April 1, 2011

I guess I didn’t cleanly redirect all my traffic from my old website since there are still people leaving comments there.  I didn’t want to lose those comments because I try to respond to all the questions and also like to thank all who visit and take time to leave comments.   So I wanted to transfer them over from my old  website to here.  Now how would I do that cleanly??  I would have to use phpMyAdmin.   You will have to get your hands a little dirty in this exercise.  Also make sure to do a full backup of your website before attempting anything with the phpMyAdmin.  If you mess something up here, you pretty much need a full backup.

First you need to start at your old domain.

1.  Login to your webhosting provider.

2.  Find the link for phpMyAdmin.  (Contact your webhost admin if you cannot find it)

3.  Login to your phpMyAdmin (Contact your webhost admin if you don’t know your password info)

4.  Click on your database and shows all the tables that you have below.

5.  Click on the table name –   dbprefix_comments.   Please note your dbprefix can be anything.  You usually specify that when you setup your Wordpress.  The table name ‘comments’ is the important part.

6.  Click on Browse tab in the big window.  You will see a bunch of rows.  Those are all your comments that people left on your website.

7.  Use the checkbox to select the comments you want to copy over.

8.  Scroll to the bottom.  You will see a text that says ‘With Selected: “.  Click on the icon that says ‘Export’.

9.  For example, I picked comment # 40 to export.  You will see a box come up that says:

Your SQL query has been executed successfully

SELECT *
FROM `dbprefix_comments`
WHERE (
(`dbprefix_comments`.`comment_ID` =40))

10.  Go down to the bottom, ignore all the other settings, and click on GO.

11.  Open with notepad.   You will see lots of weird words and stuff in the notepad but don’t worry.  Search for a term ‘INSERT INTO’.   Copy from that text down to the very end.  For example:

INSERT INTO `dbprefix_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
(40, 10, ‘Elaine’, ‘something email’, ”, ‘10.10.10.10’, ‘2011-03-11 14:38:34’, ‘2011-03-11 19:38:34’, ‘Please visit http://www.cmsmind.com for Wordpress and Joomla Tips.’, 0, ‘1’, ‘Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13’, ”, 0, 0);

Now on your New Domain.

12.  Login to your new webhosting provider.

13.  Find the link for phpMyAdmin.  (Contact your webhost admin if you cannot find it)

14.  Login to your phpMyAdmin (Contact your webhost admin if you don’t know your password info)

15.  Click on your database and shows all the tables that you have below.

16.  Click on the table name –   dbprefix_comments.   Please note your dbprefix can be anything.  You usually specify that when you setup your wordpress.  The table name ‘comments’ is the important part.

17.  Change to the ‘SQL’ tab.

18.  See the heading – ‘Run SQL query/queries on database’, copy the sql statement you have from step 11 and paste it into the text box under the heading.

19.  Click GO.

20.  The SQL message should come back saying ‘Successfully added 1 row’.

You might get an error when you run step 18 because the database prefix on your new wordpress website might be different from the one you have before.  For example, if your new wordpress database prefix is NEWdbprefix_, then change your above insert statement to be:

INSERT INTO `NEWdbprefix_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
(40, 10, ‘Elaine’, ‘something email’, ”, ‘10.10.10.10’, ‘2011-03-11 14:38:34’, ‘2011-03-11 19:38:34’, ‘Please visit http://www.cmsmind.com for WordPress and Joomla Tips.’, 0, ‘1’, ‘Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13’, ”, 0, 0);

Another error you might run into is if that comment id #40 already exists.  If so, then browse to the last page of your NEWdbprefix_comments page and see the very last comment ID and increment by 1.

Post is a little long and wordy.  I had a little trouble myself because of the database prefix difference and comment ID’s, so I hope this helps you.

 Wordpress   How to use phpMyAdmin to Export and Import Comments To Another Website

Elaine

Elaine is the founder of CmsMind, an online blog providing Joomla and WordPress tutorials. Elaine lives in Toronto and when she is not online, she is either Marathon and Triathlon training or travelling and racing somewhere in the world. Find her also at: Save Money, Premium Themes and Templates, and at Webhosting Tips.

More Posts - Website

{ 2 comments… read them below or add one }

Tommy Oddo October 30, 2011 at 3:18 am

Thanks Elaine– this was a big help… I had to move a few comments from my production server to my staging server after a major update. Thanks for posting!

Reply

Elaine October 30, 2011 at 6:29 pm

Hi Tommy,
No problem, I’m glad the post helped you!
Thanks for your visit,
elaine

Reply

Leave a Comment

Captcha Captcha Reload

Older Post:

Newer Post: