如果博客很大,通过后台的导出和导入转移博客很不方便,因为文件太大。今天在网络上看到一篇日志SQL script to migrate from Movable Type to WordPress,我觉得这个方法不错!
该SQL脚本在MovableType 5.01和WordPress 2.92下经过作者的测试,当版本升级之后,不一定能顺利转移。在使用下面代码之前,修改自己的WordPress和MovableType的数据库名字。
USE `WordPress`;
/* !!! Truncate tables to prevent primary key conflicts !!! */
TRUNCATE TABLE wp_posts;
TRUNCATE TABLE wp_comments;
TRUNCATE TABLE wp_users;
/* users from author */
INSERT INTO wp_users (
ID,
user_login,
user_pass,
user_nicename,
user_email,
user_url,
user_registered,
/* user_activation_key, */
user_status,
display_name
) (SELECT
author_id,
author_name,
author_password, /* fingers crossed */
IF (author_basename IS NOT NULL,author_basename,author_name) ,
author_email,
IF (author_url IS NOT NULL,author_url,' '),
author_created_on,
/* user_activation_key, */
author_status,
IF (author_nickname IS NOT NULL,author_nickname,author_name)
FROM MTDATABASE.mt_author);
/* post from entry */
INSERT INTO wp_posts (
ID,
post_author,
post_date,
post_date_gmt,
post_content,
post_title,
post_excerpt,
post_status,
comment_status,
ping_status,
/* post_password */
post_name,
post_modified,
post_modified_gmt, /* --post_modified_gmt, */
/* --post_content_filter, */
/* --post_parent, */
/* --guid, */
/* --menu_order, */
/* --post_type, */
/* --post_mime_type, */
comment_count,
to_ping,
pinged
) (
SELECT
entry_id,
entry_author_id,
entry_created_on,
CONVERT_TZ(entry_created_on,'+00:00','-06:00'), /* GMT */
CONCAT(entry_text,entry_text_more) ,
entry_title,
entry_excerpt,
TRIM(CAST(entry_status AS CHAR)),
TRIM(CAST(entry_allow_comments AS CHAR)),
TRIM(CAST(entry_allow_pings AS CHAR)),
/* --post_password */
entry_basename,
/* --to_ping */
/* --pinged */
entry_modified_on,
CONVERT_TZ(entry_modified_on,'+00:00','-06:00'), /* -- post_modified_gmt, */
/* --post_content_filter, */
/* --post_parent, */
/* --guid, */
/* --menu_order, */
/* --post_type, */
/* --post_mime_type, */
entry_comment_count,
'',
''
FROM mises_blog.mt_entry);
INSERT INTO wp_comments (
comment_ID,
comment_post_ID,
comment_author,
comment_author_email,
comment_author_url,
comment_author_IP,
comment_date,
comment_date_gmt,
comment_content,
/* comment_karma, junk_score? */
/* comment_approved, comment_junk_status?? */
/* comment_agent, */
/* comment_type, */
comment_parent,
user_id
) ( SELECT
comment_id,
comment_entry_id,
comment_author,
comment_email,
comment_url,
comment_ip,
comment_created_on,
CONVERT_TZ(comment_created_on,'+00:00','-06:00'), /* comment_date_gmt, */
comment_text,
/* comment_karma, */
/* comment_approved, */
/* comment_agent, */
/* comment_type, */
comment_parent_id,
comment_created_by
FROM mises_blog.mt_comment WHERE comment_junk_status = 1);
UPDATE wp_posts SET post_status = 'publish', comment_status='open', ping_status='open';
/* Specific to our DB: */
UPDATE wordpress.wp_posts SET guid = CONCAT('http://blog.mises.org/archives/', RIGHT(CONCAT('000000', ID),6), ".asp");