Convert WordPress data through SQL statements

Source: Internet
Author: User
Tags comments insert sql mysql access database mysql database

For large data on the conversion between the blog, often use the usual blog conversion program will be very slow, and error prone, for the MySQL based on the WordPress, uploaded data also has a certain limit, therefore, I've summed up some of the ways to convert Z-blog to WordPress directly through SQL statements.

For Z-blog users, you can first execute the following SQL Build data table.

CREATE TABLE blog_article (
log_id int not NULL,
Log_cateid int NULL,
Log_authorid int NULL,
Log_level int NULL,
Log_url varchar (255) NULL,
Log_title varchar (255) NULL,
Log_intro Longtext NULL,
Log_content Longtext NULL,
LOG_IP varchar () NULL,
Log_posttime datetime NULL,
log_commnums int NULL,
log_viewnums int NULL,
log_trackbacknums int NULL,
Log_tag varchar (255) NULL,
Log_istop varchar (TEN) not NULL
) Engine=innodb DEFAULT Charset=utf8 auto_increment=1;


CREATE TABLE Blog_category (
cate_id int not NULL,
Cate_name varchar (m) NULL,
Cate_order int NULL,
Cate_intro varchar (255) NULL,
Cate_count int NULL
) Engine=innodb DEFAULT Charset=utf8 auto_increment=1;


Then use the "Access database to convert MySQL database software" to convert the database to MySQL, and then directly in MySQL execute the following SQL statement to implement the conversion of the database. Here, for example, convert z-blog 1.7 to WordPress 2.3, the following is the SQL statement used for conversion, please empty the data in the following tables before executing sql:

INSERT into wp_posts (ID, Post_author, post_date, Post_date_gmt, Post_content, Post_title, Post_category, Post_excerpt, Post_status, Comment_status, Ping_status, Post_password, Post_name, to_ping, pinged, post_modified, POST_MODIFIED_GMT, Post_content_filtered, Post_parent, GUID, Menu_order, Post_type, Post_mime_type, Comment_count) SELECT Log_ID, ' 1 ', Log_ Posttime,log_posttime,log_content,log_title,log_cateid,log_intro, ' Publish ', ' open ', ' open ', ', log_id, ', ', ', Log_ Posttime, Log_posttime, ', 0, log_id, 0, ' post ', ', 0 from Blog_article;

INSERT into Wp_terms (term_id, name, Slug, Term_group) SELECT cate_id, Cate_name, Cate_intro, 0 from Blog_category;

INSERT into Wp_term_taxonomy (term_taxonomy_id, term_id, taxonomy, description, parent, count) SELECT cate_id, cate_id, ' C Ategory ', ', 0, cate_count from Blog_category;

INSERT into wp_term_relationships Select ID, post_category from wp_posts;

If the Wp-postviews plug-in is installed, you can also execute the following SQL statement to import the article into WordPress:

INSERT into ' Wp_postmeta ' select log_id, log_id, ' View ', log_viewnums from Blog_article;

For other systems to convert to WordPress, you can also use a similar approach, such as we can convert discuz comments to WordPress comments, using a statement similar to the following:

Insert Wp_comments (COMMENT_POST_ID,COMMENT_AUTHOR,COMMENT_AUTHOR_EMAIL,COMMENT_AUTHOR_URL,COMMENT_AUTHOR_IP, Comment_date,comment_date_gmt,comment_content,comment_karma,comment_approved,comment_agent,comment_type, comment_parent,user_id) Select Tid,author, ' yourname@mail.com ', ', Useip,from_unixtime (Dateline), From_unixtime ( Dateline), message,0, ' 0 ', ', ', 0,0 from t_posts;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.