Our comments policy - We Follow

How to migrate from Drupal to Wordpress - Export and import mysql script

April 19, 2008 · 0 comments

in Blogging, Tips

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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.

Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It! Digg It!
    www.sajithmr.com

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: Lesser known Firefox command line options

Next post: We've moved to Binary Turf