整理的一些实用WordPress后台MySQL操作命令

前端之家收集整理的这篇文章主要介绍了整理的一些实用WordPress后台MySQL操作命令前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

不过假设你的wordpress网站上有成百上千篇文章,而你需要进行全站范围的改动, 这时从后台逐条编辑就有点费时费力了,并且犯错的几率也会提高。 最好的方法是进入wordpressMysqL数据库执行必要的查询(改动)。 通过MysqL可以迅速地完成以上任务,为你节省更多时间。

下面要介绍的就是一些省时省力的wordpress SQL查询方法

事先备份

wordpress数据库里存储了你精心发表的每一篇文章,来自你的读者的所有评论,以及你对自己网站进行的所有个性化设置。 因此,无论你对自己有多自信,都请记住一定要事先备份wordpress数据库。 你可以通过备份插件进行备份。 为所有文章页面添加自定义字段
这段代码可以为wordpress数据库内所有文章页面添加一个自定义字段。 你需要做的就是把代码中的‘UniversalCutomField‘替换成你需要的文字,然后把‘MyValue‘改成需要的值。
<div class="codetitle"><a style="CURSOR: pointer" data="37760" class="copybut" id="copybut37760" onclick="doCopy('code37760')"> 代码如下:
<div class="codebody" id="code37760">
INSERT INTO wp_postMeta (post_id,Meta_key,Meta_value)
SELECT ID AS post_id,'UniversalCustomField'
AS Meta_key 'MyValue AS Meta_value FROM wp_postsWHERE ID NOT IN (SELECT post_id FROM wp_postMeta WHERE Meta_key = 'UniversalCustomField');

如果只需要为文章添加自定义字段,可以使用下面这段代码
<div class="codetitle"><a style="CURSOR: pointer" data="29474" class="copybut" id="copybut29474" onclick="doCopy('code29474')"> 代码如下:
<div class="codebody" id="code29474">
INSERT INTO wp_postMeta (post_id,'UniversalCustomField'
AS Meta_key 'MyValue AS Meta_value
FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postMeta WHERE Meta_key = 'UniversalCustomField')`AND post_type = 'post'; <BR></div> <BR>如果只需要为<a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a><a href="https://www.jb51.cc/tag/tianjia/" target="_blank" class="keywords">添加</a><a href="https://www.jb51.cc/tag/zidingyiziduan/" target="_blank" class="keywords">自定义字段</a>,可以使用下面这段<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="7448" class="copybut" id="copybut7448" onclick="doCopy('code7448')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code7448"&gt; <BR>INSERT INTO wp_post<a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a> (post_id,'UniversalCustomField' <BR>AS <a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>_key 'MyValue AS <a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>_value <BR>FROM wp_posts WHERE ID NOT IN <BR>(SELECT post_id FROM wp_post<a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a> WHERE <a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>_key = 'UniversalCustomField')ANDpost_type= 'page'; <BR></div> <BR><a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a><a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a><a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>数据 <BR>当你安装或<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a><a href="https://www.jb51.cc/tag/chajian/" target="_blank" class="keywords">插件</a>时,系统通过<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a><a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a><a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a>存储数据。 <a href="https://www.jb51.cc/tag/chajian/" target="_blank" class="keywords">插件</a>被<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>后,数据依然会存留在post_<a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>表中,当然这时你已经不再需要这些数据,完全可以<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>之。 记住在运行<a href="https://www.jb51.cc/tag/chaxun/" target="_blank" class="keywords">查询</a>前把<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>里的‘Your<a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>Key‘替换成你需要的相应值。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="46969" class="copybut" id="copybut46969" onclick="doCopy('code46969')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code46969"&gt; <BR>DELETE FROM wp_post<a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a> WHERE <a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>_key = 'Your<a href="https://www.jb51.cc/tag/Meta/" target="_blank" class="keywords">Meta</a>Key'; <BR></div> <BR>查找无用<a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a> <BR>如果你在<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a><a href="https://www.jb51.cc/tag/shujuku/" target="_blank" class="keywords">数据库</a>里执行<a href="https://www.jb51.cc/tag/chaxun/" target="_blank" class="keywords">查询</a><a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>旧<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>,和之前<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a><a href="https://www.jb51.cc/tag/chajian/" target="_blank" class="keywords">插件</a>时的情况一样,<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>所属<a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a>会留在<a href="https://www.jb51.cc/tag/shujuku/" target="_blank" class="keywords">数据库</a>里,并且还会出现在<a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a>列表/<a href="https://www.jb51.cc/tag/biaoqianyun/" target="_blank" class="keywords">标签云</a>里。 下面的<a href="https://www.jb51.cc/tag/chaxun/" target="_blank" class="keywords">查询</a>可以帮你找出无用的<a href="https://www.jb51.cc/tag/biaoqian/" target="_blank" class="keywords">标签</a>。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="28406" class="copybut" id="copybut28406" onclick="doCopy('code28406')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code28406"&gt; <BR>SELECT * From wp_terms wtINNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy='post_tag' AND wtt.count=0; <BR></div> <BR>批量<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a><a href="https://www.jb51.cc/tag/lajipinglun/" target="_blank" class="keywords">垃圾评论</a> <BR>执行以下<a href="https://www.jb51.cc/tag/sql/" target="_blank" class="keywords">sql</a>命令: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="10652" class="copybut" id="copybut10652" onclick="doCopy('code10652')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code10652"&gt; <BR>DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam'; <BR></div> <BR>批量<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>所有未审核<a href="https://www.jb51.cc/tag/pinglun/" target="_blank" class="keywords">评论</a> <BR>这个<a href="https://www.jb51.cc/tag/SQLchaxun/" target="_blank" class="keywords">SQL查询</a>会<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>你的网站上所有未审核<a href="https://www.jb51.cc/tag/pinglun/" target="_blank" class="keywords">评论</a>,不影响已审核<a href="https://www.jb51.cc/tag/pinglun/" target="_blank" class="keywords">评论</a>。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="37356" class="copybut" id="copybut37356" onclick="doCopy('code37356')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code37356"&gt; <BR>DELETE FROM wp_comments WHERE comment_approved = 0 <BR></div> <BR><a href="https://www.jb51.cc/tag/jinzhi/" target="_blank" class="keywords">禁止</a><a href="https://www.jb51.cc/tag/pinglun/" target="_blank" class="keywords">评论</a>较早<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a> <BR>指定comment_status的值为open、closed或registered_only。 <BR>此外还需要设置日期(<a href="https://www.jb51.cc/tag/xiugai/" target="_blank" class="keywords">修改</a><a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>中的2010-01-01): <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="57246" class="copybut" id="copybut57246" onclick="doCopy('code57246')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code57246"&gt; <BR>UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2010-01-01' AND post_status = 'publish'; <BR></div> <BR>停用/激活trackback与pingback <BR>指定comment_status的值为open、closed或registered_only。 <BR>向所有<a href="https://www.jb51.cc/tag/yonghu/" target="_blank" class="keywords">用户</a>激活pingbacks/trackbacks: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="24133" class="copybut" id="copybut24133" onclick="doCopy('code24133')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code24133"&gt; <BR>UPDATE wp_posts SET ping_status = 'open'; <BR></div> <BR>向所有<a href="https://www.jb51.cc/tag/yonghu/" target="_blank" class="keywords">用户</a>禁用pingbacks/trackbacks: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="23470" class="copybut" id="copybut23470" onclick="doCopy('code23470')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code23470"&gt; <BR>UPDATE wp_posts SET ping_status = 'closed'; <BR></div> <BR>激活/停用某一日期前的Pingbacks & Trackbacks <BR>指定ping_status的值为open、closed或registered_only。 <BR>此外还需要设置日期(<a href="https://www.jb51.cc/tag/xiugai/" target="_blank" class="keywords">修改</a><a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>中的2010-01-01): <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="98903" class="copybut" id="copybut98903" onclick="doCopy('code98903')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code98903"&gt; <BR>UPDATE wp_posts SET ping_status = 'closed' WHERE post_date < '2010-01-01' AND post_status = 'publish'; <BR></div> <BR><a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>特定URL的<a href="https://www.jb51.cc/tag/pinglun/" target="_blank" class="keywords">评论</a> <BR>当你发现很多<a href="https://www.jb51.cc/tag/lajipinglun/" target="_blank" class="keywords">垃圾评论</a>都带有相同的URL<a href="https://www.jb51.cc/tag/lianjie/" target="_blank" class="keywords">链接</a>,可以利用下面的<a href="https://www.jb51.cc/tag/chaxun/" target="_blank" class="keywords">查询</a>一次性<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>这些<a href="https://www.jb51.cc/tag/pinglun/" target="_blank" class="keywords">评论</a>。%表示含有“%"符号内字符串的所有URL都将被<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="72604" class="copybut" id="copybut72604" onclick="doCopy('code72604')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code72604"&gt; <BR>DELETE from wp_comments WHERE comment_author_url LIKE "%nastyspamurl%" ; <BR></div> <BR>识别并<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>“X"天前的<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a> <BR>查找“X"天前的所有<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>(注意把X替换成相应数值): <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="24942" class="copybut" id="copybut24942" onclick="doCopy('code24942')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code24942"&gt; <BR>SELECT * FROMwp_postsWHEREpost_type= 'post'AND DATEDIFF(NOW(),post_date) > X <BR></div> <BR><a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>“X"天前的所有<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="67927" class="copybut" id="copybut67927" onclick="doCopy('code67927')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code67927"&gt; <BR>DELETE FROMwp_postsWHEREpost_type= 'post'AND DATEDIFF(NOW(),post_date) > X <BR></div> <BR><a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>不需要的短<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a> <BR>当你决定不再使用短<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>时,它们不会<a href="https://www.jb51.cc/tag/zidong/" target="_blank" class="keywords">自动</a>消失。你可以用一个简单的<a href="https://www.jb51.cc/tag/SQLchaxun/" target="_blank" class="keywords">SQL查询</a>命令<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>所有不需要的短<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>。 把“tweet"替换成相应短<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a><a href="https://www.jb51.cc/tag/mingcheng/" target="_blank" class="keywords">名称</a>: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="92089" class="copybut" id="copybut92089" onclick="doCopy('code92089')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code92089"&gt; <BR>UPDATE wp_post SET post_content = replace(post_content,'[tweet]','' ) ; <BR></div> <BR>将<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>转为<a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a> <BR>依然只要通过<a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>MyAdmin运行一个<a href="https://www.jb51.cc/tag/SQLchaxun/" target="_blank" class="keywords">SQL查询</a>就可以搞定: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="19602" class="copybut" id="copybut19602" onclick="doCopy('code19602')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code19602"&gt; <BR>UPDATE wp_posts SET post_type = 'page' WHERE post_type = 'post' <BR></div> <BR>将<a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a>转换成<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="83949" class="copybut" id="copybut83949" onclick="doCopy('code83949')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code83949"&gt; <BR>UPDATE wp_posts SET post_type = 'post' WHERE post_type = 'page' <BR></div> <BR>更改所有<a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>上的作者<a href="https://www.jb51.cc/tag/shuxing/" target="_blank" class="keywords">属性</a> <BR>首先通过下面的<a href="https://www.jb51.cc/tag/sql/" target="_blank" class="keywords">sql</a>命令检索作者的ID: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="17466" class="copybut" id="copybut17466" onclick="doCopy('code17466')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code17466"&gt; <BR>SELECT ID,display_name FROM wp_users; <BR></div> <BR>成功<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>该作者的新旧ID后,插入以下命令,记住用新作者ID替换NEW_AUTHOR_ID,旧作者ID替换OLD_AUTHOR_ID。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="90358" class="copybut" id="copybut90358" onclick="doCopy('code90358')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code90358"&gt; <BR>UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID; <BR></div> <BR>批量<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a><a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>修订历史 <BR><a href="https://www.jb51.cc/tag/wenzhang/" target="_blank" class="keywords">文章</a>修订历史保存可以很实用,也可以很让人烦恼。 你可以手动<a href="https://www.jb51.cc/tag/shanchu/" target="_blank" class="keywords">删除</a>修订历史,也可以利用<a href="https://www.jb51.cc/tag/SQLchaxun/" target="_blank" class="keywords">SQL查询</a>给自己节省时间。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="98239" class="copybut" id="copybut98239" onclick="doCopy('code98239')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code98239"&gt; <BR>DELETE FROM wp_posts WHERE post_type = "revision"; <BR></div> <BR>停用/激活所有<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a><a href="https://www.jb51.cc/tag/chajian/" target="_blank" class="keywords">插件</a> <BR>激活某个<a href="https://www.jb51.cc/tag/chajian/" target="_blank" class="keywords">插件</a>后发现无法<a href="https://www.jb51.cc/tag/denglu/" target="_blank" class="keywords">登录</a><a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a><a href="https://www.jb51.cc/tag/guanlimianban/" target="_blank" class="keywords">管理面板</a>了,试试下面的<a href="https://www.jb51.cc/tag/chaxun/" target="_blank" class="keywords">查询</a>命令吧,它会立即禁用所有<a href="https://www.jb51.cc/tag/chajian/" target="_blank" class="keywords">插件</a>,让你重新<a href="https://www.jb51.cc/tag/denglu/" target="_blank" class="keywords">登录</a>。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="48037" class="copybut" id="copybut48037" onclick="doCopy('code48037')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code48037"&gt; <BR>UPDATE wp_options SET option_value = 'a:0:{}' WHERE option_name = 'active_plugins'; <BR></div> <BR>更改<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a>网站的目标URL <BR>把<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a><a href="https://www.jb51.cc/tag/boke/" target="_blank" class="keywords">博客</a>(模板<a href="https://www.jb51.cc/tag/wenjian/" target="_blank" class="keywords">文件</a>、<a href="https://www.jb51.cc/tag/shangchuan/" target="_blank" class="keywords">上传</a><a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>&<a href="https://www.jb51.cc/tag/shujuku/" target="_blank" class="keywords">数据库</a>)从一台服务器移到另一台服务器后,接下来你需要告诉<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a>你的新<a href="https://www.jb51.cc/tag/boke/" target="_blank" class="keywords">博客</a>地址。 <BR>使用以下命令时,注意将http://www.old-site.com换成你的原URL,http://blog.doucube.com换成新<a href="https://www.jb51.cc/tag/URLdizhi/" target="_blank" class="keywords">URL地址</a>。 <BR>首先: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="25202" class="copybut" id="copybut25202" onclick="doCopy('code25202')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code25202"&gt; <BR>UPDATE wp_options <BR>SET option_value = replace(option_value,'http://www.old-site.com','http://blog.doucube.com') <BR>WHERE option_name = 'home' OR option_name = 'siteurl'; <BR></div> <BR>然后利用下面的命令更改wp_posts里的URL: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="20265" class="copybut" id="copybut20265" onclick="doCopy('code20265')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code20265"&gt; <BR>UPDATE wp_posts SET guid = replace(guid,'http://blog.doucube.com); <BR></div> <BR>最后,<a href="https://www.jb51.cc/tag/sousuo/" target="_blank" class="keywords">搜索</a><a href="https://www.jb51.cc/tag/wenzhangneirong/" target="_blank" class="keywords">文章内容</a>以确保新URL<a href="https://www.jb51.cc/tag/lianjie/" target="_blank" class="keywords">链接</a>与原<a href="https://www.jb51.cc/tag/lianjie/" target="_blank" class="keywords">链接</a>没有弄混: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="8516" class="copybut" id="copybut8516" onclick="doCopy('code8516')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code8516"&gt; <BR>UPDATE wp_posts SET post_content = replace(post_content,' http://www.ancien-site.com ',' http://blog.doucube.com '); <BR></div> <BR>更改默认<a href="https://www.jb51.cc/tag/yonghuming/" target="_blank" class="keywords">用户名</a>Admin <BR>把其中的YourNewUsername替换成<a href="https://www.jb51.cc/tag/xinyonghu/" target="_blank" class="keywords">新用户</a>名。 <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="43764" class="copybut" id="copybut43764" onclick="doCopy('code43764')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code43764"&gt; <BR>UPDATE wp_users SET user_login = 'YourNewUsername' WHERE user_login = 'Admin'; <BR></div> <BR>手动重置<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a>密码 <BR>如果你是你的<a href="https://www.jb51.cc/tag/wordpress/" target="_blank" class="keywords">wordpress</a>网站上的唯一作者,并且你没有<a href="https://www.jb51.cc/tag/xiugai/" target="_blank" class="keywords">修改</a>默认<a href="https://www.jb51.cc/tag/yonghuming/" target="_blank" class="keywords">用户名</a>, 这时你可以用下面的<a href="https://www.jb51.cc/tag/SQLchaxun/" target="_blank" class="keywords">SQL查询</a>来重置密码(把其中的PASSWORD换成新密码): <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="38019" class="copybut" id="copybut38019" onclick="doCopy('code38019')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code38019"&gt; <BR>UPDATEwordpress.wp_usersSETuser_pass= MD5('PASSWORD') <BR>WHEREwp_users.user_login=adminLIMIT 1; <BR></div> <BR><a href="https://www.jb51.cc/tag/sousuo/" target="_blank" class="keywords">搜索</a>并替换<a href="https://www.jb51.cc/tag/wenzhangneirong/" target="_blank" class="keywords">文章内容</a> <BR>OriginalText换成被替换<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>,ReplacedText换成目标<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>: <BR><div class="codetitle"&gt;<span><a style="CURSOR: pointer" data="81813" class="copybut" id="copybut81813" onclick="doCopy('code81813')"&gt;<U></U></a> <a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>如下:</div><div class="codebody" id="code81813"&gt; <BR>UPDATE wp_posts SETpost_content= REPLACE (post_content`,'OriginalText','ReplacedText');

更改图片URL
下面的sql命令可以帮你修改图片路径:
<div class="codetitle"><a style="CURSOR: pointer" data="23874" class="copybut" id="copybut23874" onclick="doCopy('code23874')"> 代码如下:
<div class="codebody" id="code23874">
UPDATE wp_postsSET post_content = REPLACE (post_content,'src="http://www.myoldurl.com','src="http://blog.doucube.com');

原文链接:https://www.f2er.com/php/26826.html
MySQL操作命令

猜你在找的PHP相关文章