Migrating nodes from Drupal 6 to 7

Sean Wragg
Jan 31, 2011 · 2 min read
Image for post
Image for post

(attow) Sadly, there doesn’t seem to be a straight forward method for importing content nodes from Drupal 6 to Drupal 7 without installing a module. Albeit, this isn’t the “best” method but hopefully, this snippet will at least assist in filling the void. There are a few caveats however.

:

  • This snippet requires the use of Node 1 but, can be replaced/removed after import.
  • This snippet will reorder your Node IDs (nids) but, will keep your URL aliases intact.
  • This snippet only imports “page” content types but, can easily be modified for others.
  1. First, you’ll need to add your Drupal 6 database to the Druapl 7 $databases array. We accomplish this by modifying then appending the following code to our Drupal 7 settings.php. Naturally, you’ll need to replace the provided information with your connection information.
$databases['drupal6']['default']  (
'driver' 'mysql',
'database' 'database',
'username' 'username',
'password' 'password',
'host' 'hostname',
'prefix' '',
);
  • Enable the PHP Filter module. (if not already enabled)
  • Clear Drupal 7 Cache
  • Replace Node 1 (yoursite.com/node/1) or Create your first Basic Page node. Title the node as you wish, select the Text format as “PHP Code”, then paste the following code within the body.
  • Visit yoursite.com/node/1 and click “Import Nodes”. It may take a few minutes depending on how many nodes being imported.

:

  • If you receive the error “PDOException: SQLSTATE[42000] [1049] Unknown database…” double check your database connection in settings.php then try clearing the Drupal 7 cache.

sean3z

Code, Comics, and Fhqwhgads!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store