How To Migrate From Drupal To WordPress — Export And Import Mysql Script

April 19, 2008

wordpress

I figured it our the hard way that migrating from Drupal to WordPress is not at all easy. While numerous attempts have been made by people to create SQL scripts to make the transition easier, the structure of databases has changed over a period of time. I was following the instructions at http://www.rufuspollock.org/2005/10/10/migrating-drupal-to-wordpress/ and failed to import the posts. Thus I made my own SQL script for importing the posts. Essentially Drupal now uses an extra table called node-revisions which contains the body. Everything else goes in the table called node.

Here’s the script. “wp” is the name of the wordpress database and “drupal” is the name of the drupal database.

INSERT INTO wp23.wp_posts (
ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_name, post_modified, post_modified_gmt, post_type)

SELECT node.nid, node.uid, FROM_UNIXTIME(node.created), FROM_UNIXTIME(node.created), node_revisions.body, node.title, node_revisions.teaser, concat('node/', node.nid), FROM_UNIXTIME(node.changed), FROM_UNIXTIME(node.changed),'page'
FROM drupal.node, drupal.node_revisions WHERE node.type = 'page' AND node.nid = node_revisions.nid

Use it in conjunction with the other scripts to import comments, etc.

 

Join 37,807 others and get free tutorials & tips on design & development using Wordpress on, Thesis & Genesis!

{ 2 comments on How To Migrate From Drupal To WordPress — Export And Import Mysql Script… read them below or add one }

Tony July 5, 2011 at 8:48 am

Thanks heaps, I was able to successfully use many of these scripts in the migration of my Travel Thailand website http://www.bangkoktravelthailand.com from Drupal to Wordpress. Saved me heaps of time and effort. Thumbs up!

ruben December 2, 2011 at 2:48 am

great post, i just run the script and the migration was done.
much appreciated

Comment on How To Migrate From Drupal To WordPress — Export And Import Mysql Script

You can add images to your comment by clicking here.

Previous post:

Next post:

X

Wordpress, Thesis, Genesis tutorials from Binary Turf — one tutorial a day. Subscribe & sharpen your web design skills.

Name:

Email:

We respect your email privacy.