Wordpress数据恢复用到的一些代码

 接前一篇文章:mysql根据.frm和.ibd文件恢复表结构和数据

数据库只要.ibd文件完整就可以恢复数据,.frm文件不需要。

数据库建表:

--
-- 表的结构 `wp_commentmeta`
--

Create TABLE `wp_commentmeta` (
`meta_id` bigint(20) UNSIGNED NOT NULL,
`comment_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_comments`
--

Create TABLE `wp_comments` (
`comment_ID` bigint(20) UNSIGNED NOT NULL,
`comment_post_ID` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`comment_author` tinytext COLLATE utf8mb4_unicode_ci NOT NULL,
`comment_author_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_author_url` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_author_IP` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`comment_karma` int(11) NOT NULL DEFAULT '0',
`comment_approved` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1',
`comment_agent` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'comment',
`comment_parent` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`user_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_links`
--

Create TABLE `wp_links` (
`link_id` bigint(20) UNSIGNED NOT NULL,
`link_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`link_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`link_image` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`link_target` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`link_description` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`link_visible` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Y',
`link_owner` bigint(20) UNSIGNED NOT NULL DEFAULT '1',
`link_rating` int(11) NOT NULL DEFAULT '0',
`link_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`link_rel` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`link_notes` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
`link_rss` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_options`
--

Create TABLE `wp_options` (
`option_id` bigint(20) UNSIGNED NOT NULL,
`option_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`option_value` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`autoload` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'yes'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_postmeta`
--

Create TABLE `wp_postmeta` (
`meta_id` bigint(20) UNSIGNED NOT NULL,
`post_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_posts`
--

Create TABLE `wp_posts` (
`ID` bigint(20) UNSIGNED NOT NULL,
`post_author` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`post_title` text COLLATE utf8mb4_unicode_ci NOT NULL,
`post_excerpt` text COLLATE utf8mb4_unicode_ci NOT NULL,
`post_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'publish',
`comment_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
`ping_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'open',
`post_password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`post_name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`to_ping` text COLLATE utf8mb4_unicode_ci NOT NULL,
`pinged` text COLLATE utf8mb4_unicode_ci NOT NULL,
`post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content_filtered` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`post_parent` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`guid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`menu_order` int(11) NOT NULL DEFAULT '0',
`post_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'post',
`post_mime_type` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment_count` bigint(20) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_posts2`
--

Create TABLE `wp_posts2` (
`ID` bigint(20) UNSIGNED NOT NULL,
`post_title` text COLLATE utf8mb4_unicode_ci NOT NULL,
`post_name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_termmeta`
--

Create TABLE `wp_termmeta` (
`meta_id` bigint(20) UNSIGNED NOT NULL,
`term_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_terms`
--

Create TABLE `wp_terms` (
`term_id` bigint(20) UNSIGNED NOT NULL,
`name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`slug` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`term_group` bigint(10) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_term_relationships`
--

Create TABLE `wp_term_relationships` (
`object_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`term_taxonomy_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`term_order` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_term_taxonomy`
--

Create TABLE `wp_term_taxonomy` (
`term_taxonomy_id` bigint(20) UNSIGNED NOT NULL,
`term_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`taxonomy` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`description` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`parent` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`count` bigint(20) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_usermeta`
--

Create TABLE `wp_usermeta` (
`umeta_id` bigint(20) UNSIGNED NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

-- --------------------------------------------------------

--
-- 表的结构 `wp_users`
--

Create TABLE `wp_users` (
`ID` bigint(20) UNSIGNED NOT NULL,
`user_login` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_pass` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_nicename` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_url` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`user_activation_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_status` int(11) NOT NULL DEFAULT '0',
`display_name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT;

--
-- 转储表的索引
--

--
-- 表的索引 `wp_commentmeta`
--
Alter TABLE `wp_commentmeta`
ADD PRIMARY KEY (`meta_id`),
ADD KEY `comment_id` (`comment_id`),
ADD KEY `meta_key` (`meta_key`(191));

--
-- 表的索引 `wp_comments`
--
Alter TABLE `wp_comments`
ADD PRIMARY KEY (`comment_ID`),
ADD KEY `comment_post_ID` (`comment_post_ID`),
ADD KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`),
ADD KEY `comment_date_gmt` (`comment_date_gmt`),
ADD KEY `comment_parent` (`comment_parent`),
ADD KEY `comment_author_email` (`comment_author_email`(10));

--
-- 表的索引 `wp_links`
--
Alter TABLE `wp_links`
ADD PRIMARY KEY (`link_id`),
ADD KEY `link_visible` (`link_visible`);

--
-- 表的索引 `wp_options`
--
Alter TABLE `wp_options`
ADD PRIMARY KEY (`option_id`),
ADD UNIQUE KEY `option_name` (`option_name`),
ADD KEY `autoload` (`autoload`);

--
-- 表的索引 `wp_postmeta`
--
Alter TABLE `wp_postmeta`
ADD PRIMARY KEY (`meta_id`),
ADD KEY `post_id` (`post_id`),
ADD KEY `meta_key` (`meta_key`(191));

--
-- 表的索引 `wp_posts`
--
Alter TABLE `wp_posts`
ADD PRIMARY KEY (`ID`),
ADD KEY `post_name` (`post_name`(191)),
ADD KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
ADD KEY `post_parent` (`post_parent`),
ADD KEY `post_author` (`post_author`);

--
-- 表的索引 `wp_posts2`
--
Alter TABLE `wp_posts2`
ADD PRIMARY KEY (`ID`),
ADD UNIQUE KEY `post_name` (`post_name`(191)) USING BTREE,
ADD KEY `type_status_date` (`ID`);

--
-- 表的索引 `wp_termmeta`
--
Alter TABLE `wp_termmeta`
ADD PRIMARY KEY (`meta_id`),
ADD KEY `term_id` (`term_id`),
ADD KEY `meta_key` (`meta_key`(191));

--
-- 表的索引 `wp_terms`
--
Alter TABLE `wp_terms`
ADD PRIMARY KEY (`term_id`),
ADD KEY `slug` (`slug`(191)),
ADD KEY `name` (`name`(191));

--
-- 表的索引 `wp_term_relationships`
--
Alter TABLE `wp_term_relationships`
ADD PRIMARY KEY (`object_id`,`term_taxonomy_id`),
ADD KEY `term_taxonomy_id` (`term_taxonomy_id`);

--
-- 表的索引 `wp_term_taxonomy`
--
Alter TABLE `wp_term_taxonomy`
ADD PRIMARY KEY (`term_taxonomy_id`),
ADD UNIQUE KEY `term_id_taxonomy` (`term_id`,`taxonomy`),
ADD KEY `taxonomy` (`taxonomy`);

--
-- 表的索引 `wp_usermeta`
--
Alter TABLE `wp_usermeta`
ADD PRIMARY KEY (`umeta_id`),
ADD KEY `user_id` (`user_id`),
ADD KEY `meta_key` (`meta_key`(191));

--
-- 表的索引 `wp_users`
--
Alter TABLE `wp_users`
ADD PRIMARY KEY (`ID`),
ADD KEY `user_login_key` (`user_login`),
ADD KEY `user_nicename` (`user_nicename`),
ADD KEY `user_email` (`user_email`);

--
-- 在导出的表使用AUTO_INCREMENT
--

--
-- 使用表AUTO_INCREMENT `wp_commentmeta`
--
Alter TABLE `wp_commentmeta`
MODIFY `meta_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_comments`
--
Alter TABLE `wp_comments`
MODIFY `comment_ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_links`
--
Alter TABLE `wp_links`
MODIFY `link_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_options`
--
Alter TABLE `wp_options`
MODIFY `option_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_postmeta`
--
Alter TABLE `wp_postmeta`
MODIFY `meta_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_posts`
--
Alter TABLE `wp_posts`
MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_posts2`
--
Alter TABLE `wp_posts2`
MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_termmeta`
--
Alter TABLE `wp_termmeta`
MODIFY `meta_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_terms`
--
Alter TABLE `wp_terms`
MODIFY `term_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_term_taxonomy`
--
Alter TABLE `wp_term_taxonomy`
MODIFY `term_taxonomy_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_usermeta`
--
Alter TABLE `wp_usermeta`
MODIFY `umeta_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- 使用表AUTO_INCREMENT `wp_users`
--
Alter TABLE `wp_users`
MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;

 

数据库恢复需要的一些操作命令:

rm -f wp_comments.frm

rm -f wp_links.frm

rm -f wp_options.frm

rm -f wp_postmeta.frm

rm -f wp_posts.frm

rm -f wp_termmeta.frm

rm -f wp_terms.frm

rm -f wp_term_relationships.frm

rm -f wp_term_taxonomy.frm

rm -f wp_usermeta.frm

rm -f wp_users.frm

 

alter table wp_commentmeta discard tablespace;

alter table wp_comments discard tablespace;

alter table wp_links discard tablespace;

alter table wp_options discard tablespace;

alter table wp_postmeta discard tablespace;

alter table wp_posts discard tablespace;

alter table wp_termmeta discard tablespace;

alter table wp_terms discard tablespace;

alter table wp_term_relationships discard tablespace;

alter table wp_term_taxonomy discard tablespace;

alter table wp_usermeta discard tablespace;

alter table wp_users discard tablespace;

 

cp -f wp_commentmeta.ibd /storage/data/jcblog

cp -f wp_comments.ibd /storage/data/jcblog

cp -f wp_links.ibd /storage/data/jcblog

cp -f wp_options.ibd /storage/data/jcblog

cp -f wp_postmeta.ibd /storage/data/jcblog

cp -f wp_posts.ibd /storage/data/jcblog

cp -f wp_termmeta.ibd /storage/data/jcblog

cp -f wp_terms.ibd /storage/data/jcblog

cp -f wp_term_relationships.ibd /storage/data/jcblog

cp -f wp_term_taxonomy.ibd /storage/data/jcblog

cp -f wp_usermeta.ibd /storage/data/jcblog

cp -f wp_users.ibd /storage/data/jcblog

 

alter table wp_commentmeta import tablespace;

alter table wp_comments import tablespace;

alter table wp_links import tablespace;

alter table wp_options import tablespace;

alter table wp_postmeta import tablespace;

alter table wp_posts import tablespace;

alter table wp_termmeta import tablespace;

alter table wp_terms import tablespace;

alter table wp_term_relationships import tablespace;

alter table wp_term_taxonomy import tablespace;

alter table wp_usermeta import tablespace;



[本日志由 admin 于 2022-01-06 06:42 AM 更新]
上一篇: LNMP一键安装包安装的mysql远程连接不上的问题
下一篇: nginx屏蔽指定的user_agent访问
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: wordpress mysql
相关日志:
评论: 0 | 引用: 0 | 查看次数: 67
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭

 广告位

↑返回顶部↑