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

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 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.


  1. Thanks heaps, I was able to successfully use many of these scripts in the migration of my Travel Thailand website from Drupal to WordPress. Saved me heaps of time and effort. Thumbs up!

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

  3. I just did it manually! Only had a 100 or so posts to move ….. oh well!


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

Your email address will not be published. Required fields are marked *