前提条件 首先安装好 solo,创建用户保证可以访问。 确保 wordpress 数据库与 solo 数据库可以同时访问。 执行脚本 以 solo 数据库为访问库,wordpress 数据库被我命名为 wp 了,如果命名不一致,将 wp 改为你的 wordpress 数据库名即可。 导入文章表数据 INSERT INT ..

从 wordpress 迁移到 b3log - solo

前提条件

  1. 首先安装好 solo,创建用户保证可以访问。
  2. 确保 wordpress 数据库与 solo 数据库可以同时访问。

执行脚本

以 solo 数据库为访问库,wordpress 数据库被我命名为 wp 了,如果命名不一致,将 wp 改为你的 wordpress 数据库名即可。

导入文章表数据

INSERT INTO b3_solo_article

SELECT
	posts.id AS oId
	,posts.post_title AS articleTitle
	,'' AS articleAbstract
	,'' AS articleAbstractText
	,(SELECT
			group_concat(terms.name)
		FROM
			wp.wp_terms terms,
			wp.wp_term_relationships rs
		WHERE
			terms.term_id = rs.term_taxonomy_id
		AND rs.object_id = posts.ID
		GROUP BY rs.object_id ) AS articleTags
	,(select oId from b3_solo_user LIMIT 1) AS articleAuthorId
	,0 AS articleCommentCount
	,0 AS articleViewCount
	,posts.post_content AS articleContent
	,concat('/articles/',year(posts.post_date),'/',LPAD(month(posts.post_date), 2, 0),'/',LPAD(DAY(posts.post_date),2,0),'/',posts.id,'.html') AS articlePermalink
	,0 AS articlePutTop
	,concat(unix_timestamp(posts.post_date),'000') AS articleCreated
	,concat(unix_timestamp(posts.post_date),'000') AS articleUpdated
	,RAND() AS articleRandomDouble
	,1 AS articleSignId
	,1 AS articleCommentable
	,'' AS articleViewPwd
	,'https://img.hacpai.com/bing/20180320.jpg?imageView2/1/w/1280/h/720/interlace/1/q/100' AS articleImg1URL
	,(CASE WHEN posts.post_status = 'publish' THEN 0 ELSE 1 END) AS articleStatus
FROM
	wp.wp_posts posts
WHERE posts.post_parent = 0
AND posts.post_type != 'nav_menu_item'
AND posts.post_type != 'page'

导入存档日期表数据

INSERT INTO b3_solo_archivedate
SELECT DISTINCT
	concat(
		unix_timestamp(
			str_to_date(
				concat(
					YEAR (posts.post_date),
					'-',
					LPAD(MONTH(posts.post_date), 2, 0),
					'-01'
				),
				'%Y-%m-%d'
			)
		),
		'000'
	) AS oId
	,concat(
		unix_timestamp(
			str_to_date(
				concat(
					YEAR (posts.post_date),
					'-',
					LPAD(MONTH(posts.post_date), 2, 0),
					'-01'
				),
				'%Y-%m-%d'
			)
		),
		'000'
	) AS archiveDate_oId
FROM
	wp.wp_posts posts
WHERE
	posts.post_parent = 0
AND posts.post_type != 'nav_menu_item'
AND posts.post_type != 'page'

GROUP BY concat(
		unix_timestamp(
			str_to_date(
				concat(
					YEAR (posts.post_date),
					'-',
					LPAD(MONTH(posts.post_date), 2, 0),
					'-01'
				),
				'%Y-%m-%d'
			)
		),
		'000'
	)

导入存档 - 文章关联表数据

INSERT INTO b3_solo_archivedate_article
SELECT
	posts.id AS oId,
	concat(
		unix_timestamp(
			str_to_date(
				concat(
					YEAR (posts.post_date),
					'-',
					LPAD(MONTH(posts.post_date), 2, 0),
					'-01'
				),
				'%Y-%m-%d'
			)
		),
		'000'
	) AS archiveDate_oId,
	posts.id AS article_oId
FROM
	wp.wp_posts posts
WHERE
	posts.post_parent = 0
AND posts.post_type != 'nav_menu_item'
AND posts.post_type != 'page'

导入标签表数据

INSERT INTO b3_solo_tag
SELECT
	term_id AS oId,
	name AS tagTitle
FROM
	wp.wp_terms

导入标签 - 文章关联表数据

INSERT INTO b3_solo_tag_article
SELECT
	CONCAT(object_id,term_taxonomy_id) AS oId,
	object_id AS article_oId,
	term_taxonomy_id AS tag_oId
FROM
	wp.wp_term_relationships

完成

  • Solo

    Solo 是一款小而美的开源博客系统,专为程序员设计。

    Solo 有着非常活跃的社区,可将文章作为帖子推送到社区,来自社区的回帖将作为博客评论进行联动。

    这是一种全新的网络社区体验,让热爱记录和分享的你不再感到孤单!
    具体细节请浏览 B3log 构思

    723 引用 • 5468 回帖 • 695 关注
  • WordPress

    WordPress 是一个使用 PHP 语言开发的博客平台,用户可以在支持 PHP 和 MySQL 数据库的服务器上架设自己的博客。也可以把 WordPress 当作一个内容管理系统(CMS)来使用。WordPress 是一个免费的开源项目,在 GNU 通用公共许可证(GPLv2)下授权发布。

    37 引用 • 96 回帖 • 538 关注
  • 数据迁移
    5 引用 • 13 回帖
回帖   
请输入回帖内容...