wordpress两个数据库内容复制:
对于主键ID等,遇到原有内容跳过,没有添加;非常好,可以很好保留老站内容又可以添加新来内容。
【完美案例】
1 2 3 4 5 |
insert into 新库.wp_posts ( id,post_content, post_title ) select id,post_content,post_title from 老库.wp_posts where( not exists (select id from 新库.wp_posts where 老库.wp_posts.id=新库.wp_posts.id)) and 老库.wp_posts.post_status = "publish" |
【例】
1 2 3 4 5 |
insert into temp001.wp_posts ( id,post_content, post_title ) select id,post_content,post_title from simiao.wp_posts where( not exists (select id from temp001.wp_posts where simiao.wp_posts.id=temp001.wp_posts.id)) |
【good】
1 2 3 4 5 |
insert into temp001.wp_posts ( id,post_content, post_title ) select id,post_content,post_title from sakesi.wp_posts where( not exists (select id from temp001.wp_posts where sakesi.wp_posts.id=temp001.wp_posts.id)) and sakesi.wp_posts.post_status = "publish" |
【wp_posts】
1 2 3 4 5 |
insert into temp001.wp_posts ( id,post_content, post_title,post_status,guid,post_type ) select id,post_content,post_title,post_status,guid,post_type from xpfengshui666.wp_posts where( not exists (select id from temp001.wp_posts where xpfengshui666.wp_posts.id=temp001.wp_posts.id)) and xpfengshui666.wp_posts.post_status = "publish" |
【wp_terms】
1 2 3 4 5 |
insert into temp001.wp_terms ( term_id,name, slug ) select term_id,name,slug from xpfengshui666.wp_terms where( not exists (select term_id from temp001.wp_terms where xpfengshui666.wp_terms.term_id=temp001.wp_terms.term_id)) |
【wp_term_relationships】
1 2 3 4 5 |
insert into temp001.wp_term_relationships ( object_id,term_taxonomy_id ) select object_id,term_taxonomy_id from xpfengshui666.wp_term_relationships where( not exists (select object_id from temp001.wp_term_relationships where xpfengshui666.wp_term_relationships.object_id=temp001.wp_term_relationships.object_id)) |
【wp_term_taxonomy】
1 2 3 4 5 |
insert into temp001.wp_term_taxonomy ( term_id,term_taxonomy_id,taxonomy,description,count ) select term_id,term_taxonomy_id,taxonomy,description,count from xpfengshui666.wp_term_taxonomy where( not exists (select term_id from temp001.wp_term_taxonomy where xpfengshui666.wp_term_taxonomy.term_id=temp001.wp_term_taxonomy.term_id)) |
导入mysql数据的时候提示Field * doesn’t have a default value解决方法:
宝塔mysql配置修改:
1 |
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
改为
1 |
sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
上面是默认数据库严格模式,下面是早期版宽松模式,建议导完数据后改回