微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用WordPress内置的工具修复和优化数据库

站长朋友们在使用wordpress建设好网站以后,当自己的WordPress网站上线运行了一段比较长的时间以后,一般都会在数据库中产生一些垃圾数据。或者在使用不当的情况下,会导致某些数据库表的损坏,这个时候我们就需要对数据库表进行修复和优化。站长朋友们比较常用的是使用 PHPMyAdmin 内置的优化和修复功能,但是这个工具只能应用于 MyISAM 类型的数据表,无法应用于 InnoDB 类型的数据表。

其实,wordpress内置了一个优化和修复数据库的工具,它既可以应用于 MyISAM 类型的数据表,也可以应用于 InnoDB 类型的数据表。要开启这个工具很简单,在网站根目录下的 wp-config.php 文件
“/* 好了!请不要再继续编辑。请保存本文件。使用愉快! */”
前面,添加下面的代码即可:

Crayon-5c891ce253183787347674" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">wp-config.php
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891ce253183787347674-1">1
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891ce253183787347674-1">Crayon-e">defineCrayon-sy">(Crayon-s">'WP_ALLOW_REPAIR'Crayon-sy">,Crayon-h"> Crayon-t">trueCrayon-sy">)Crayon-sy">;

然后访问如下地址即可访问到该优化和修复工具:

Crayon-5c891ce25318c890116568" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891ce25318c890116568-1">1
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891ce25318c890116568-1">Crayon-v">httpCrayon-o">:Crayon-c">//您的域名/wp-admin/maint/repair.PHP

如下图:

youhuaxiufu

点击相应的按钮即可进行操作,有问题的话会返回相应的信息给您。
提示:在“修复并优化数据库”时,如果第一次没有生效,请多试几次,有时候需要多次执行才能完成。

重要提示
1. 在执行此操作之前,请务必先手动下载备份好您的数据库,以防数据丢失。
2. 在不使用该工具的时候,请将 define(‘WP_ALLOW_REPAIR’,true); 的true 改为 false,或删除这行代码

当然,如果你不想通过编辑 wp-config.php 文件添加 define(‘WP_ALLOW_REPAIR’,true); ,您也可以安装并启用 wordpress-plugin-enable-database-tools/" target="_blank" rel="nofollow">Enable WP Database Tools 这款wordpress插件,它可以自动开启优化和修复数据库的工具。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐