首页 编程开发emlog博客系统迁移到WordPress的过程记录

emlog博客系统迁移到WordPress的过程记录

分类:编程开发
字数: 4444
评论: 1
阅读: 5894
摘要:

emlog博客系统的官网在2017年6月底突然关闭了,疑似被攻击。具体还会不会恢复访问不得而知,没有官网和社区支持,再优秀的开源软件也会慢慢没落。再考虑到emlog已2-3年没有过更新,于是毅然决定将博客转为全球最为流行的wordpress,以下是迁移的过程。

以下步骤均假设自己的数据库名称为demo, 且命令是在MySQLWorkbench软件中连接到自己的数据库中执行的。且默认您的网站仅安装了emlog

1. 删除emlog

首先将自己的emlog网站中的源码和数据备份到自己的电脑中,以防整个过程出错造成不可挽回的损失。备份完成后,删除除/content/uploadfile目录之外的所有文件

2. 安装wordpress

  • 下载wordpress: https://cn.wordpress.org/

  • 将wordpress的缘码上传到根目录

  • 在浏览器中访问自己的网站地址https://www.demo.com/,页面会自动跳转到wordpress的安装界面

  • 按要求填写相应信息,即可成功安装wordpress

  • 数据库信息就填写安装emlog的数据库demo

3. 将emlog数据库导入到wordpress数据库

安装好wordpress后,数据库中存在了emlog和wordpress两个系统的数据表,其中emlog的表前缀为emlog_(默认情况), wordpress的表前缀是wp_ (默认情况) 

迁移文章数据

新建查询, 输入以下SQL语句 (先清空wp_posts表)

insert into demo.wp_posts(
    ID,
    post_author,
    post_title,
    post_date,
    post_date_gmt,
    post_content,
    post_excerpt,
    post_modified,
    post_modified_gmt,
    guid,
    comment_count,
    to_ping,
    pinged,
    post_content_filtered,
    post_type
) select gid as ID,
    author as post_author,
    title as post_title,
    FROM_UNIXTIME(date, '%Y-%m-%d %k:%i:%s' ) as post_date,
    FROM_UNIXTIME(date - 28800, '%Y-%m-%d %k:%i:%s' ) as post_date_gmt,
    content as post_content,
    excerpt as post_excerpt,
    FROM_UNIXTIME(date, '%Y-%m-%d %k:%i:%s' ) as post_modified,
    FROM_UNIXTIME(date - 28800, '%Y-%m-%d %k:%i:%s' ) as post_modified_gmt,
    concat('https://192.168.2.253:8099/?page_id=' , gid) as guid,
    (select count(*) as count from demo.emlog_comment where gid = ID and hide='n') as comment_count,
    '' as to_ping, 
    '' as pinged, 
    '' as post_content_filtered,
    if(type='blog', 'post', 'page') as post_type
    FROM demo.emlog_blog;

其中的 https://192.168.2.253:8099 为安装wordpress的域名地址, 运行完这句就导入好了文章数据

迁移评论数据

新建查询,输入一下SQL语句 (先清空wp_comments表) insert into demo.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_parent,comment_agent,comment_type) SELECT cid as comment_ID, gid as comment_post_ID, poster as comment_author, mail as comment_author_email, url as comment_author_url, ip as comment_author_IP, FROM_UNIXTIME(date, '%Y-%m-%d %k:%i:%s' ) as comment_date, FROM_UNIXTIME(date - 28800, '%Y-%m-%d %k:%i:%s' ) as comment_date_gmt, comment as comment_content, pid as comment_parent, '' as comment_agent, '' as comment_type FROM demo.emlog_comment;

迁移分类数据

新建查询,输入以下SQL语句 (先清空wp_terms表) insert into demo.wp_terms(term_id, name, slug) SELECT sid as term_id, sortname as name, alias as slug FROM demo.emlog_sort;

迁移分类与父分类的关系

新建查询,输入以下SQL语句 (先清空wp_term_taxonomy表) insert into demo.wp_term_taxonomy(term_id, taxonomy, description, parent, count) SELECT sid as term_id, 'category' as taxonomy, description, pid as parent, (select count(*) from demo.emlog_blog where sortid = term_id)  as count FROM demo.emlog_sort;

迁移文章与分类的关系表

新建查询,输入以下SQL语句 (先清空wp_term_relationships表) insert into demo.wp_term_relationships(object_id, term_taxonomy_id) SELECT gid as object_id, (select term_taxonomy_id from demo.wp_term_taxonomy where term_id = sortid) as term_taxonomy_id FROM demo.emlog_blog where sortid != -1; 整个过程没有对文章中的附件做处理, 迁移过程中保持本地附件路径不变即可.(即第1步不删除/content/uploadfile目录的原因)。

4. 设置wordpress

迁移完成后, 需自己进入wordpress的后台, 设置下模板、网站信息、URL的形式、用户信息等即可正常访问自己的wordpress版博客。

5. 备注

本次迁移将文章信息,评论信息,分类信息等都迁移到wordpress中,丢弃了碎语,导航,设置,用户信息等跟wordpress不通用的信息。

文章发布于: 2017-07-03 04:35:32

扫描二维码,在手机上阅读
评论列表:
jaeheng
2017-07-22 09:03
这个不错啊