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.

Forewarning:

  • 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'] = array(
'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.

Troubleshooting:

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

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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