May
15
(2007)
I migrated my blog from Drupal 5 to WordPress 2 nearly 2 weeks ago. The process wasn’t as painful as I thought it would be, thanks to a handy howto via vrypan.net. Another resource I refer to every time I get into tweaking MySQL rows is UrbanMainframe’s MySQL search and replace tipsheet. Thanks to both of these great resources for helping me through the migration.
This guide is intended only to document what I did. It’s not a polished howto or manual. There is no warranty. If you blow up your database because you didn’t work with offline backup copies, I won’t be able to help you. Actually, if you’re that silly, I won’t be willing to help you, either. Your mileage may vary.
Use a backup copy of your Drupal database, and a fresh WordPress database.
The basic process I followed was:
- Work from offline copies of the databases. Dump your Drupal 5 database, import it into a fresh database (say “
drupalmigration” or something creative). I did the migration on a separate machine from my “live” server – I used my desktop box, with local copies of MySQL and Apache. Anything with a decent version of MySQL on it will do. - Install WordPress, (you don’t need to install Drupal for this migration) using the same database server containing the copy of your Drupal database (use “
wordpress” as the name of the new WordPress database). - Now that you’ve got WordPress and Drupal running on the same database server, in separate databases, run this MySQL script which I modified slightly after the file provided by vrypan.net. The script assumes the WordPress database is called “
wordpress” and the Drupal database is called “drupalmigration” – feel free to modify the script to match the database names you need to use, if they differ. - That should do it. Log into your WordPress site. You might have to hand tweak the usernames, but all posts and comments should be there…
One additional thing I had to do was fix the comment_ID values in the wp_comments table. After migration, they were too big for the data type, and things went poopy. I’m sure there’s an elegant way to renumber rows in MySQL. I used brute force, by dumping the table to a .sql file and opening that in a text editor to do a search-and-replace to lower the numbers used as primary keys. I then moved the old table out of the way (renaming it to “wp_comments_old“) and imported the new wp_comments table definition and content. It was a funky thing to have to do, but it solved all kinds of comment-related misbehaviour.
Test things out in the migrated database. If all seems well, go ahead and dump the wordpress database to a .sql file, and import it into a new database on your server. Install and configure WordPress on your server to use this new database. You may need to manually change the URL used by the blog, so that it matches the “live” server rather than whatever you used as a staging/migration server. The values are in the wp_options table, with option_name of “siteurl” and “home” – change those values to whatever matches the root URL for your blog.
You’ll also have to make sure all files are in the proper place, so URL references from the old Drupal content doesn’t point off to 404 error pages. That’s an exercise left to the reader. I just SSHed into my server and used a lot of cp -R drupal/directoryname wordpress/directoryname – being paranoidally careful to copy files rather than just moving them. Always keep backups.
Update: I’ve updated the SQL script to automatically set the comment and category counts, so it should appear to work better now.


This one is Digg worthy;)
just wait for the WordPress-to-Drupal re-migration process to be documented…
Great stuff, just what I need
I really need to move dslrblog over to wordpress, drupal is hindering rather than helping me over there
Thanks, this works pretty well, only one problem. On the main page it says “no comments” even for posts that have comments. How would you fix that.
Ibrahim: That’s related to WordPress’ caching of the comment count for each post as a field on the wp_posts table so it doesn’t have to count the comments each time it displays the count.
I believe I ran the SQL from here:
http://www.brendanloy.com/2007/02/wordpress-21-upgrade-problems.html
I should add that as the last step of the migration script…
OK. Updated the .sql script. It should now properly update both comment count and category count cache values.
[...] real key was the script I found on D’Arcy Norman’s blog. D’Arcy did the migration a few weeks ago and detailed it all on his blog. He made generous [...]
[...] My friend Damian and I have just been moving DSLRBlog from Drupal 5 to WordPress 2 using instructions from D’Arcy Norman. [...]
When I submitted a comment I ended up at http://www.darcynorman.net/wp-comments-post.php which is a http 404.
Hmm, worked here. The post I was commenting on was http://www.darcynorman.net/2007/07/03/macosx-vs-ubuntu/ .
Also the a href’s to full size images in http://www.darcynorman.net/2006/09/06/dells-media-pc-is-twice-as-expensive-as-an-imac/ 404 .
Hope that helps.
@Lloyd: Looks like my spam blocker decided not to like you for some reason. Sorry! I’ve rescued your comment on the Ubuntu post. I have no idea why it bumped you to wp-comments-post.php with a 404 error, though. Bizarre… Sorry about that.
Hello darcy. I’m enhancing and unifying some other migration scripts, and putting a tutorial together along the way. the final detail to resolve is permalinks. With drupal I had my “clean URLs” with underscores from the root of my URL e.g. site.com/article_is_here. I can update Wordpress config to work in this fashion using the first link, but I can’t get permalinks to work using the info at the second link. In your case you said you did a lot of copying. Could you expand on that a bit or suggest the best way to avoid 404s for all my existing Google cache? Thanks!
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
http://codex.wordpress.org/Using_Permalinks
Hello. I found this reference on URL rewriting and it seems to have enough examples for me to apply to my situation. If you have any other good ones, please drop me a line. Thanks.
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
[...] assist with the moving everything back I had a search about on the web and found a simple guide here. The conversion script worked perfectly, and I was up and running in under half an hour. A quick [...]
Hi there! I had some trouble when trying to use this script on my Drupal 5 blog (currently) to WordPress 2.3. When I tried to use the script, this error kept popping up: “#1146 – Table ‘wordpress.wp_categories’ doesn’t exist”. And it is correct. I am assuming this is because I am using the latest version of WordPress, which is V.2.3.
I will try installing WordPress V.2 and see what happens! I will keep you updated.
Whew! After some tweaking here and there (mostly because of my hosting – it had nothing to do with your wonderful script!), I finally got it to work. You saved me an incredible amount of time. Thank you so much!
[...] and did the unthinkable; I migrated my blog from Drupal to WordPress. I found a great resource, over at D’Arcy Norman dot net, that helped me immensely with copying over the tables, etc. to the new [...]
one should note – this works splendidly up to wordpress 2.2, but in 2.3 they seem to have done away with “categories” and now have a “term” and “taxonomy” structure. this means that if you follow all these steps with a wordpress 2.3 database, you get everything except categories assigned properly. (you’ll get the same error that Binary Blonde got, above — this script tries to delete from a table, then insert into a table, that doesn’t exist)
an easy solution is to instead install wordpress 2.2, import your data, then upgrade wordpress 2.2 to 2.3. if you cannot do that (my host has a “one click install” for 2.3) what i did instead was make my 2.3 database *look* like a 2.2 database again, import the data, then use wordpress’ wp-admin/upgrade.php page to move the database from 2.2 to 2.3.
even with this fiddling, you saved me oodles and oodles of time. thanks!
[...] 参考文章以及作者提供的SQL转换代码:How to migrate from Drupal 5 to WordPress 2 [...]
Hello, I’m curious as to why established Drupallers are opting for WP? I’m guessing its a usability improvement (n.b. Drupal did win this year’s Packt CMS award http://www.packtpub.com/award) ?
Drew, it’s not a comment on the quality of Drupal – I use it on nearly every project I work on – but just that it makes sense to choose the right tool for the job. Drupal _can_ do blogging properly, if you spend some time configuring and tweaking it. WordPress _can_ do websites, if you spend some time tweaking. But, if you use each tool for the tasks they excel at, you’ll wind up with Drupal powering high-end dynamic websites, and WordPress running a blog. They’re both awesome bundles of code, but they are best applied in their own respective areas of focus.
[...] http://www.darcynorman.net/2007/05/15/how-to-migrate-from-drupal-5-to-wordpress-2/ [...]
[...] assist with the moving everything back I had a search about on the web and found a simple guide here. The conversion script worked perfectly, and I was up and running in under half an hour. A quick [...]
Thanks a lot for the MySQL Sheet. I was doing the reverse process (Wordpress to Drupal) and I couldn’t solve the node types. A simple database replacement and -woooo – it runs. Things could be so easy…
[...] last night and managed to transfer all of the data in a couple hours of work. The key was this sql script to transfer everything, which is a little bit old and required installing Wordpress 2.0, importing, [...]
I think the database files are the most important point on moving to wordpress. Thanks for the useful tips.
Thanks for making this page
My Conversion is Drupal 5.2 to WP wordpress-2.0.4 old version downloaded only for conversion.
the script works good except…..
If you have many categories in Drupal like
Government
- State – state names
and
Business – State Names
It will choke a bit and shoot everything into uncatagorized
AND for people that use CCK and Address Fields
that content is not stored in the normal area of content
So if like me you have lots of businesses listed on pages using special CCK fields
The script will make the page blank and you will have to manualy copy the info
All in all though you saved me a MRI and Brain Aneurysm
)
[...] http://www.darcynorman.net/2007/05/15/how-to-migrate-from-drupal-5-to-wo... Fantastic Drupal to Wordpress migration post with an SQL script that works quite well. You need to migrate to Wordpress 2.0 for it to work. [...]
Thanks for this guide it really helped in the migration process with our corporate blog. We had a little bit of hangups in the process but overall it was a great success! I’m bookmarking this page if I ever need it again ~ Cheers Jason
Has anyone yet modified this for a Drupal5->WP 2.5.x Migration? This should be quite different due to the new term-stuff in WP?
@Frank
I am looking for a solution for this too.
Hi , I’d like to migrate my old drupal 5 gallery content to my Wordpress gallery (which is actually a WP Blog with images/videos as seperate posts).any tips i should follow?thanks!
While I have not done this for WP 2.5.1 directly, I don’t think the changes to the SQL script would be that hard to make. I may look at it later, but I still have more work to do on the site I needed to convert from Drupal 5 to Wordpress.
I installed WP 2.2, then made some changes to the SQL script, because the site I’m converting has many contributors, and on my first conversion attempt, this script didn’t do anything to import users, no names, no logins, no passwords. I had to add that info into the SQL script.
Another mod I had to make was to accomodate how database users are handled in Plesk. There’s no easy way to give a single mysql user access to multiple databases in Plesk, and the workaround requires root and/or shell access. It was easier for me to do a mysqldump of the Drupal database and import everything into my new WP database… none of the table names overlapped, so that seemed to be the simple and obvious workaround.
So I imported the Drupal db tables into my WP db, then changed the script to not refer to external databases, and the script ran like a charm. It brought my users over, kept their same passwords, and their ownership of various articles. Once that was done, I upgraded WP from 2.2 to 2.5.1, and now the new site is running just fine, and all it needs is some cleanup to work in my new template.
Once I finish some more individual tweaking to take advantage of the new magazine-style Wordpress template I’m using, I’ll just drop the Drupal tables from my WP db, and be done with it.
I may take another look at the SQL script later, because there is one other Drupal site that needs to be converted, and I’d like to avoid the “instal WP 2.2 / Upgrade to WP 2.5″ step, if I can.
I’m looking for a solution to migrate from Drupal5 –> Serendipity without WP-workaround
I too am looking for a way to migrate a Drupal 5.3 installation into WordPress 2.5.1 or 2.6 depending on timing. I have yet to come across anything that would make this remotely feasible to do on my own. No scripts or anything to move to a newer version of WordPress.
So this comment is for you Dnorman. I write for a big named website who has been using drupal since 2005 and we now want to move to WordPress but are finding ourselves facing a huge brick wall. It looks like you have experience migrating things over between drupal and WordPress and I’d like to know if you would talk to me off of the blog either through email or skype about a possible project for you or at least, explain what is possible and what is not possible in terms of migration.
Looking forward to hearing from you.
Any solution from WP 2.6 (latest) to Drupal? A have a blog not to complex, with text and images.
Has anyone yet modified this for a Drupal5->WP 2.5.x Migration? This should be quite different due to the new term-stuff in WP?
Thanks a lot for the MySQL Sheet. I was doing the reverse process (Wordpress to Drupal) and I couldn’t solve the node types. A simple database replacement and -woooo – it runs. Things could be so easy…
Anyone know if this works for Drupal 5 to current version of WP? Am also wondering if anyone has had problems migrating content due to Drupal modules (I’m using a blog module for posts).
Hi, I’m trying to use this script for Drupal 5 to WP 2.6.3 and I got the following error:
crida SQL:
DELETE FROM wp_categories;
MySQL diu:
#1146 – Table ‘MYDB_wordpress.wp_categories’ doesn’t exist
I guess the same will happen with the wp_post2cat table referenced in the script.
Could anyone provide some assistance in adapting the script to WP2.6.3?
Thanks!
The SQL script doesn’t seem to work with WordPress 2.6, like AlbertC mentioned above. It also doesn’t convert Drupal node revisions. (WordPress supports post revisions since version 2.6.)
A few months ago I updated this script and migrated my site from
Drupal 5.9 to WP 2.6. My inelegant hack of D’Arcy’s excellent
script worked, but I couldn’t get the categories to transfer
properly, so I just did those manually. Posts and comments came
across fine, though. If you’re facing a similar transition and
don’t mind that limitation, feel free to try my version
(http://dovdox.com/content/archives/135). Standard disclaimers
apply.
[...] most of my blogs to WordPress. Now is small howto, how I made that. First thanks (and sources): http://www.darcynorman.net/ , http://blog.componentoriented.com/ and [...]
Thanks this was extremely useful for getting a huge set of posts migrated from drupal with taxonomy intact.
How long does it takes to migrate drupal to wordpress? (the whole proces)
It depends. It could take a few minutes, with an updated version of the script, or it could take days. And is your name really “Drupal Hosting”? They do have some odd names in Belgium. Sadly, your comment smells a bit spammy.
Here’s the link to the bit on setting up .htaccess: http://blog.componentoriented.com/?p=196
I’ve been on WordPress for six months or so, now, and I like it a lot better for blogging. WordPress isn’t quite as flexible as Drupal, though, so if you need tons of customization, you may want to stick with Drupal.
The SQL script doesn’t seem to work with WordPress 2.6, like AlbertC mentioned above. It also doesn’t convert Drupal node revisions. (WordPress supports post revisions since version 2.6.)
Thanks for the script! I managed to transfer most of my posts and comments from my old drupal 5 site to wordpress effortlessly. I had neglected my drupal site mostly because of it’s clunkiness, it feels as if I take a lot of time to do very simple things.