Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to migrate an existing website to WordPress. This website already has a basic database containing users and posts (with a category), but it also has a high number of records so it's not possible to do it manually.

What is the best way to import them into my WordPress database? Should I try to export the old one into a CVS file or something similar?

share|improve this question
    
Although your target is WordPress, this is really more of an ETL question than a WordPress question. You might get a better answer at the dba or stackoverflow.com –  Stephen Nov 5 '12 at 19:42
add comment

3 Answers

up vote 3 down vote accepted

Unless there is a core Wordpress import filter available for your CMS ( see http://codex.wordpress.org/Importing_Content ) or a plugin for a CMS not covered by core WP ( see http://wordpress.org/extend/plugins/search.php?q=import ), or a Google search for your database schema doesn't reveal anything, you need to roll your own importer.

The best way is to write a MySQL query that will take your current data and move it into the Wordpress database structure. That can be complex, but in the end, it's the most efficient and accurate method.

But you can also try exporting from the database using phpmyadmin into CSV and then working with that file with Excel or text editors to get the content into the correct Wordpress table schema and import that CSV with phpmyadmin ( see http://codex.wordpress.org/Database_Description or try a CSV import plugin http://wordpress.org/extend/plugins/search.php?q=import+CSV ). That's obviously less MySQL intensive, if you're not that great with queries.

Or you can try building and then importing a WXR file, WP's special import format used for moving content between Wordpress installs. Export a few posts and pages from a test Wordpress site to get a sample WXR file to determine the format ( see http://codex.wordpress.org/Tools_Export_Screen ). And then take a text export of your database and "massage" it into a WXR file.

Another idea is to set up an RSS feed for your site and import that way; see http://codex.wordpress.org/Importing_Content#Importing_from_an_RSS_feed But that won't get users or categories, only posts.

share|improve this answer
add comment

What about "simply" writing a SQL script that populates the wp_posts, wp_users,... wordpress tables with the contents of your current ones?

Not for your specific CMS but you´ll be able to find example scripts for other CMS that you could use as starting point

share|improve this answer
add comment

You can write a simple php script to query your database, pull out the relevant data, and then use wp_insert_post to create the posts automatically in wordpress (http://codex.wordpress.org/Function_Reference/wp_insert_post). You'll need to have included wp-blog-header.php in your script to use wp_insert_post.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.