又把部落格從 drupal 搬回到 wordpress ,因為實在太忙,沒有空玩drupal的強大功能,也沒空維持它。而單純以書寫來說,wordpress是方便多了。不過,搬回來實在很麻煩…這是drupal故意的嗎?呵呵

必須要使用SQL的指令修改資料,所以必需要有phpMyadmin、相關權限與一定程度的語法知識(不必太厲害,會操作即可)。

參考:http://socialcmsbuzz.com/convert-import-a-drupal-6-based-website-to-wordpress-v27-20052009/

step1. 首先,你要先安裝一個新的wordpress系統,SQL資料庫名為「tempdb」(如果不是這個名字,以下指令請自行修改)

step2 然後將 drupal 6 的 SQL database 備份出來,再輸入到 wordpress 的資料庫「tempdb」中。

step3 依照以下語法,一一修改

(1) 輸入前清除表格

TRUNCATE TABLE tempdb.wp_comments;
TRUNCATE TABLE tempdb.wp_links;
TRUNCATE TABLE tempdb.wp_postmeta;
TRUNCATE TABLE tempdb.wp_posts;
TRUNCATE TABLE tempdb.wp_term_relationships;
TRUNCATE TABLE tempdb.wp_term_taxonomy;
TRUNCATE TABLE tempdb.wp_terms;

(2) 匯入分類與標籤

INSERT INTO tempdb.wp_terms (term_id, `name`, slug, term_group)
SELECT
d.tid, d.name, REPLACE(LOWER(d.name), ' ', '-'), 0
FROM tempdb.term_data d
INNER JOIN tempdb.term_hierarchy h
USING(tid)
;

INSERT INTO tempdb.wp_term_taxonomy (term_id, taxonomy, description, parent)
SELECT
d.tid `term_id`,
'category' `taxonomy`,
d.description `description`,
h.parent `parent`
FROM tempdb.term_data d
INNER JOIN tempdb.term_hierarchy h
USING(tid)
;

(3) 匯入文章內容

INSERT INTO
    tempdb.wp_posts (id, post_date, post_content, post_title,
    post_excerpt, post_name, post_modified)
SELECT DISTINCT
    n.nid, FROM_UNIXTIME(created), body, n.title,
    teaser,
    REPLACE(REPLACE(REPLACE(REPLACE(LOWER(n.title),' ', '-'),'.', '-'),',', '-'),'+', '-'),
    FROM_UNIXTIME(changed)
FROM tempdb.node n, tempdb.node_revisions r
WHERE n.vid = r.vid

(4) 連結文章與分類

INSERT INTO tempdb.wp_term_relationships (object_id, term_taxonomy_id)
SELECT nid, tid FROM tempdb.term_node;

Category Count Updating

UPDATE wp_term_taxonomy tt
SET `count` = (
 SELECT COUNT(tr.object_id)
 FROM wp_term_relationships tr
 WHERE tr.term_taxonomy_id = tt.term_taxonomy_id
);

(5) 隱藏未驗證回應

INSERT INTO tempdb.wp_comments (comment_post_ID, comment_date, comment_content, comment_parent, comment_author, comment_author_email, comment_author_url, comment_approved)
SELECT nid, FROM_UNIXTIME(timestamp), comment, thread, name, mail, homepage, status FROM tempdb.comments;

(6) 更新文章回應數

UPDATE `wp_posts` SET `comment_count` = (SELECT COUNT(`comment_post_id`) FROM `wp_comments` WHERE `wp_posts`.`id` = `wp_comments`.`comment_post_id`);

(7) 修正斷行符號

UPDATE tempdb.wp_posts SET post_content = REPLACE(post_content, '', '');

(8) 修正圖檔位置

UPDATE tempdb.wp_posts SET post_content = REPLACE(post_content, '"/sites/default/files/',

step4 完成資料庫修正後,可把 tempdb 中 druapl 的資料表刪除,並把 wordpress 的資料表移到真正的 wordpress 資料庫中。

step5 中文部分顯示若有問題,記得到 wp-config.php 中加入以二行。

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', 'utf8_general_ci');

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: